Skip to content
Advertisement

HTTP post request?param=PARAM vs –data-urlencode

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.

Advertisement

Answer

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

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement