InfluxDB v2.0.0-alpha Query API via Postman

Hi

I am trying to use Postman to test queries on v2.0.0-alpha. I cannot find any examples using the JSON body with the “query” key. Documentation says “query”: “string”. I have tried the following as the JSON body:

{
“query”: “from(bucket: ‘datasourceId’) |> range(start: -1h, stop: -1m) |> filter(fn: ® => r._measurement == ‘m’) |> filter(fn: ® => r._field == ‘q’) |> filter(fn: ® => r.t== ‘name001’)”
}

But get the following response:
{
“code”: “invalid”,
“message”: “failed to execute query against proxy service”,
“op”: “http/handlePostQuery”,
“error”: {
“code”: “invalid”,
“message”: “compilation failed: loc 1:6-1:27: invalid expression @1:27-1:28: '”
}
}

Thanks

donot use json as content type, just raw test. Like this:

Hi @kilik52, thanks for your response.

However, even when using the “Text” body of:

from(bucket: “datasourceId”) |> range(start: -10h)

I am getting the following error response:
{
“code”: “invalid”,
“message”: “failed to decode request body”,
“op”: “http/handlePostQuery”,
“error”: “invalid character ‘r’ in literal false (expecting ‘a’)”
}

I am not sure which character ‘r’ is causing the issue?

Hope you can assist.
Thanks

u may upload some screenshot. let me see ur headers and body

Thanks @kilik52. See my screenshots. The only header I am adding is the Token.

try add another header:

Content-Type: application/vnd.flux

1 Like

Hi, I’m trying to make API call to query data from my Influxdb 2.0 v2.0.0-alpha db using Postman but I cant receive data in json format.


Is it there some parameter that I miss or do I have to use Flux Json package in some way?
Thanks in advance

Flux results are returned in annotated CSV only. There isn’t an option for JSON output.