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.jsonhttp://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
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”}
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 ?