0

i am just querying my InfluxDB and i made it work, but i never did web so i am not so experienced with http protocol. I need to do curl request.

This one works fine:

curl -X POST http://localhost:8086/api/v2/query?orgID=12345678 --header "Authorization: Token MYTOKEN" --header "Content-Type: application/vnd.flux" --data-binary 'from(bucket:"MYBUCKET") |> range(start: -55m) |> yield()'

But this does not and i dont understand why, i thought it is the same thing just differently put.

curl -X POST http://localhost:8086/api/v2/query --data-urlencode "orgID=12345678" --header "Authorization: Token MYTOKEN" --header "Content-Type: application/vnd.flux" --data-binary 'from(bucket:"MYBUCKET") |> range(start: -55m) |> yield()'

I guess no need for u to understand Influx to help me, I post this question after an hour of research and I just dont have time for this right now, can someone please just explain the concept to me? I can make it work obviously but this frustrates me since i thought its the same thing.

Thanks four the time, Q.

Jan Janáček
  • 109
  • 1
  • 9

1 Answers1

1

The mistake - is that you sends two payloads. The first example contains orgId as url parameter. In second orgId sent like payload and also sent data with influx query.

curl -X POST http://localhost:8086/api/v2/query 
--data-urlencode "orgID=12345678"  <-- FIRST PAYLOAD 
--header "Authorization: Token MYTOKEN" --header "Content-Type: application/vnd.flux" 
--data-binary 'from(bucket:"MYBUCKET") |> range(start: -55m) |> yield()' <-- SECOND PAYLOAD

And when you send such a request, it just takes the last payload

Amerousful
  • 2,292
  • 1
  • 12
  • 26
  • Thank you, i thought --data-urlencode is not a payload, i thought it is just a way of passing arguments to url in different way – Jan Janáček Dec 03 '21 at 12:33