InfluxDB and Unity. Able to write, unable to query

I’ve been testing out various database solutions to possibly integrate into my Unity project as means of storing coordinate data (in longitude-latitude pairs). Due to a recommendation from a co-worker I’ve also tried using Influx for this.

Upon testing this out, it seems I am able to write data into a bucket through a script inside Unity, BUT I am somehow not able to read the data from the same bucket. My solution is a 99% copy of the InfluxDB C# tutorial. And as mentioned, the data writing into the bucket works with this solution. When I however try to query data from the bucket I get the following error:

“Error during query: Status(StatusCode=“Unauthenticated”, Detail=“unauthenticated”)”

If I try to run my solution in Visual Studio outside Unity, the querying works. Is there something I am missing or not taking into account (some setting etc) in my Unity solution, or are InfluxDB and Unity just incompatible?

I would greatly appreciate any and all help.

@Topias_Nykanen, a few questions:

  • What version of InfluxDB are you using?
  • Can you provide the code that is querying?

The status code indicates that the query request is not authenticating correctly, but authentication methods depend on the version of InfluxDB you’re using.

Thanks for your reply!

The influx version I’m using is the serverless cloud version 3 (just the simple free-tier for testing purposes). The query code is shown below. (It is pretty much the code provided in the InfluxDB C# tutorial. The content of the table being queried is also based on the census-data from that tutorial)

try
{
// Execute the query and handle the results
await foreach (var row in client.Query(query: sql, database: “buckee”))
{
Debug.Log(row[1]);
}

}
catch (Exception ex)
{
Debug.LogError($“Error during query: {ex.Message}”);
}

I have the InfluxDB3.Client installed in unity through NuGet for Unity- tool. I have the below package installed:

Could this package possibly have something to do with the unauthorizatoin error? Upon searching InfluxDB packages through the tool, there appear to be various other options as well (for example just a plain "InfluxDB.Client).

Thanks!