I am using Grafana official documentation as reference to query a data source via python. Should queries be sent as payload or params when using Grafana
/api/ds/query
I have come up the following Python code but it returns me “{‘message’: ‘id is invalid’}”.
headers = {"Accept": "application/json",
"Content-Type": "application/json",
"X-Grafana-Org-Id": "<org-id>",
"Authorization": "Bearer <your token here>"
}
api_url = f"{grafana_url}/api/ds/query"
payload = {
"queries": [
{
"refId": "A",
"datasource": {
"uid": "<your data-source uid here>"
},
"format": "table",
}
],
"from": "now-1y",
"to": "now"
}
response = requests.post(api_url, json=payload, headers=headers,verify = False)
response.json()
I know the data-source uid I am using is correct because I am able to make calls through following api:
/api/datasources/uid/:uid
This doesn’t makes sense to me.