Grafana API does not work, could you help me figure it out?

github issue : Grafana API does not work, could you help me figure it out? · Issue #7838 · grafana/grafana · GitHub

Dashboards
Create / Update dashboard
POST /api/dashboards/db

What Grafana version are you using?
4.0.2

What datasource are you using?
prometheus

What OS are you running grafana on?
mac pro 10.12.3

What did you do?
POST /api/dashboards/db
as in page http://docs.grafana.org/reference/http_api/#create-update-dashboard

What was the expected result?
create OK

What happened instead?
<Response [404]>
{u’message’: u’Not found’}

If related to metric query / data viz:

Include raw network request & response: get by opening Chrome Dev Tools (F12, Ctrl+Shift+I on windows, Cmd+Opt+I on Mac), go the network tab.

Can you show the full request url & request method & body your sending to Grafana?

of cos

I use the json exactly as the guide doc done as below:

Create / Update dashboard
POST /api/dashboards/db

Creates a new dashboard or updates an existing dashboard.

Example Request for new dashboard:

POST /api/dashboards/db HTTP/1.1
Accept: application/json
Content-Type: application/json
Authorization: Bearer eyJrIjoiT0tTcG1pUlY2RnVKZTFVaDFsNFZXdE9ZWmNrMkZYbk

{
“dashboard”: {
“id”: null,
“title”: “Production Overview”,
“tags”: [ “templated” ],
“timezone”: “browser”,
“rows”: [
{
}
],
“schemaVersion”: 6,
“version”: 0
},
“overwrite”: false
}
JSON Body schema:

dashboard – The complete dashboard model, id = null to create a new dashboard
overwrite – Set to true if you want to overwrite existing dashboard with newer version or with same dashboard title.

what I got in my response is that:
{u’message’: u’Not found’}

and this kind of response is not in the guide book.

Guide doc says that:

Status Codes:

200 – Created
400 – Errors (invalid json, missing or invalid fields, etc)
401 – Unauthorized
412 – Precondition failed
The 412 status code is used when a newer dashboard already exists (newer, its version is greater than the version that was sent). The same status code is also used if another dashboard exists with the same title.

Must be something wrong with the URL your calling or maybe your not setting Content-Type header, or something.

what does the dashboard model look like? Please show exact details of your call

[{u’message’: u’Required’, u’classification’: u’RequiredError’, u’fieldNames’: [u’Name’]}, {u’message’: u’Required’, u’classification’: u’RequiredError’, u’fieldNames’: [u’Type’]}, {u’message’: u’Required’, u’classification’: u’RequiredError’, u’fieldNames’: [u’Access’]}]

This is the error message
I donot know what happened

I donot know if we need fieldNames like Name/Type/Access
These three filed names are not in my dashboard export json file.
What is going on?

What I export to a file can not be imported to the system?
It is unnormal I think.

/api/datasources

And now this API is already ok for me.

/api/dashboards/db
Only dashboard API is NOT working, have you tested it?
I currently use the official example do the http post and the same result returns as my own json file.

It is my problem, and now I solved this since a small mistake, sorry for that.
Sorry to have disturbed you!
Thank you!

I’m having the same issue. Can you share your resolution please?
Thanks

I am trying to import dashboard using grafna API. But I get error as below.
[{“fieldNames”:[“Dashboard”],“classification”:“RequiredError”,“message”:“Required”}]
Please any one help me to solve this error.
Please include this information:
What Grafana version are you using?

5.1.3
What datasource are you using?

Influx
What OS are you running grafana on?

Windows
What did you do?

Here is my python code
import requests

headers = {
‘Content-Type’: ‘application/json;charset=UTF-8’,
}

data = open(‘C:/Users/Mahadev/Desktop/Dashboard.json’, ‘rb’).read()
response = requests.post(‘http://admin:admin@community.grafana.com/api/dashboards/db’, headers=headers, data=data)
print (response.text)

And cURL -
curl --user admin:admin “http://grafana.staged-by-discourse.com/api/dashboards/db” -X POST -H “Content-Type:application/json;charset=UTF-8” --data-binary @c:/Users/Mahadev/Desktop/Dashboard.json

Hello, have you resolved this problem? I’m having the same issue. Can you share your resolution please?