2

I downloaded the latest version of InfluxDB, it's influxdb2-2.0.3_darwin_amd64. I want to write data to the InfluxDB, and followed the documentation of "Use InfluxDB API". I got the "unauthorized access" message.

 curl --request POST "http://localhost:8086/api/v2/write?org=9682c3eaabb5384c&bucket=test_bucket&precision=s" \
 --header "Authorizations: TOKEN _XHOou59351P2Y8JjVDRWNMN22phTUzDVpUJtN85Dby6rfKSjDmGnxWTS_CbjZj-TJn7EaEduDwgtQyOY3BUeg==" \
 --data-raw "mem,host=host1 used_percent=23.43234543 1556896326"

{"code":"unauthorized","message":"unauthorized access"}

The token was copied from the web UI. enter image description here

Could anyone help me to solve this authentication problem? Thanks in advance.

choes
  • 141
  • 1
  • 1
  • 11

2 Answers2

9

I didn't follow the documentation exactly, it's case sensitive. It's "Token", not "TOKEN".

--header "Authorization: Token YOURAUTHTOKEN"
choes
  • 141
  • 1
  • 1
  • 11
-2

Try this

`curl --request POST  http://localhost:8086/api/v2/query?org=yourOrgName --header 'Authorization: Token tokenValue' --header 'Accept: application/csv' --header 'Content-type: application/vnd.flux' --data 'from(bucket:"BucketName") |> range(start: 0)|> filter(fn: (r) => r["_measurement"] == "MeasurementName")'`
  • 2
    As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-ask). – Community Sep 12 '21 at 12:55