Error with python requests while writing data to influxDB

Sample Code:

url = “http://localhost:9999/api/v2/write
params = {‘org’:‘qwerty’, ‘bucket’:‘initial’}
data = {‘baby’,‘symbol’:‘test’,‘name’:‘test1’}
response = requests.request(“POST”, url, params=params, data=data, headers=headers1)
print(response.code)

data format not working with line protocol

Hello @gudivadakoti,

Thank you for your question. Can you please print the request?

Is curl successful?

curl "http://localhost:9999/api/v2/write?org=YOUR_ORG&bucket=YOUR_BUCKET&precision=s" \
  --header "Authorization: Token YOURAUTHTOKEN" \
  --data-raw "mem,host=host1 used_percent=23.43234543 1556896326"

Or maybe try the CLI to see if you can write data at all

./influx write @/pwd/lineprotocol.txt -o "Influx" -b "Anais" -t "<$your token>"

Have you had a chance to check out the documentation here ?

@Ana, Thanks for response. Curl is working fine.

But I try write using JSON data format via python requests module. It seems that not accepting data in JSON format.

hi @gudivadakoti you resolve that?

I fixed it by directly passing the string in Line Protocol to the data parameter on the requests.post