Hi there,
I am trying to query and download the data from InfluxDB v2 from a python based API.
I converting the CuRL command to python requests using the following code:
import requests
headers = {
‘Authorization’: ‘Token pcSpeRibWx0XxxxxxxxxxxxxxxxxxxxxxxxxxxxQTuQ==’,
‘Content-Type’: ‘application/json’,
‘Accept’: ‘/’,
‘Connection’: ‘keep-alive’,
}
data = {
‘from(bucket:“test2”) | > range(start: -12h) | > filter(fn: (r) = > r._measurement == “example-measurement”) | > aggregateWindow(every: 1 h, fn: mean)’
}
response = requests.post('http:/20.83.xxx.xxx:8086/api/v2/query?org=‘xxxx’, headers=headers, data=data)
However, it gives the following error:
TypeError: a bytes-like object is required, not ‘str’
Any kind of help/feedback on this would be appreciated. Thanks