Grafana API create dashboard API with Python

As per documentation:

URL = “URL-DUMMY/api/dashboards/db”
data = {
“dashboard”: “{ ‘id’: null, ‘uid’: null, ‘title’: ‘Production Overview’, ‘tags’: [ ‘templated’ ], ‘timezone’: ‘browser’, ‘schemaVersion’: 6, ‘version’: 0 }”, “message”: “Made changes to xyz”}

headers = {“Accept”: “application/json”, “Content-Type”: “application/json”,
“Authorization”: “Bearer LONG TOKEN”}

response =
url, data=data, headers=headers, allow_redirects=False)

b’{“message”:“bad request data”}’

Not sure what the issue is

1 Like

Hello are u based in India?

Hi - I have the same issue as user above. I can’t create / update dashboards in Grafana using API via Python. This is despite following the API documentation.

Can someone please provide the correct JSON body schema for creation / updation of dashboards? Current one in API documentation doesn’t work.

Please post what you have tried?

Sending you snippet of my code below. The folder gets created but I get a ‘400’ error when I try to create dashboard:

import requests
import json

url_dest = ‘URL_DUMMY/api/’
headers_dest = {
‘Accept’: ‘application/json’,
‘Content-Type’: ‘application/json’,
‘Authorization’: ‘Bearer API_KEY_DUMMY’

s = requests.Session()
s.headers = headers_dest

new_fldr_data = {
“uid”: “l3KqBxCMz”,
“title”: “Test Folder”
r = + ‘folders’, headers=headers_dest, data = json.dumps(new_fldr_data))

db_data = {
“dashboard”: {
“id”: None,
“uid”: None,
“title”: “Production Overview”,
“tags”: [ “templated” ],
“timezone”: “browser”,
“schemaVersion”: 16,
“version”: 0,
“refresh”: “25s”
“folderId”: 0,
“folderUid”: “l3KqBxCMz”,
“message”: “Made changes to xyz”,
“overwrite”: False

r = + ‘dashboards/db’, headers=headers_dest, json = json.dumps(db_data))

Hi - Following up. I have sent you the code in a separate reply. Any ideas / resolution on the same yet?

1 Like
r =
url = url_dest + 'dashboards/db', 
headers = headers_dest, 
data = json.dumps(db_data), verify=False)


json = json.dumps(db_data)



Thank you yosiasz for providing above resolution to my query!

1 Like