Unable to create grafana dashboard through api but working through UI (import option) with same Json file

HI All,

I am using Grafana v4.2 , I am new to grafana & looking to create a dashboard through api instead of using GUI . I can able to create dashboard through GUI by importing the json file, but nit able to make through API with same json file … I have verified my json file in https://jsonlint.com/ it showed as valid …

I used below syntax
curl -X POST --insecure -H “Authorization: Bearer api-key” -H “Content-Type: application/json” -d @test-file.json http://localhost:port/api/dashboards/db

I see below error
[{“fieldNames”:[“Dashboard”],“classification”:“RequiredError”,“message”:“Required”}]

so , i have added dashboard field to my json file

“dashboard”: {

}
after adding this I am seeing below error

{“message”:“Dashboard not found”,“status”:“not-found”}

Kindly help me here to generate the dashboard through api . Thanks in advance

checkout the docs:

http://docs.grafana.org/http_api/dashboard/#create-update-dashboard

It is working fine for the sample request as listed in the given link, but in same format when i execute my json file ,I am seeing the below error .
{“message”:“Dashboard not found”,“status”:“not-found”}

I’m guessing that problem is this:

dashboard – The complete dashboard model, id = null to create a new dashboard

and that the id is not null so Grafana is trying to update a dashboard that does not exist. Could that be the problem?

Thanks Daniellee It helped .Initially I have assigned a value to the id … Now when I have assigned it to null , there after I can able to create the dashboard.

There are also id for panels. Should they be on null too ? I have complexe dashboard with repeating panels and many variables and querys. I copied the “panel” : […] part of my json Dashboard and added it to the json of this link. My request succed, i have my variables but i have no panels. I dont know what is the problem. As i said there are many id fields in the json. I assigned a null value to the Dashboard id and the uid, but what about the others ?

I too also got the same problem so i have replaced the “dashboard” with “Dashboard” char changed then it is working.