Hello ,
I try to move dashboard with the api to a folder A in the folder B.
The folder A is a folder provisioned with all the dashboard
The folder B is a folder created with the API
then i try something like that
curl -XPOST -H “Content-Type: application/json” -d ‘{ “dashboard”: { “uid”:“THE_UID_OF_MY_EXISTING-DASHBOARD” ,“title”:“the title of my dashboard”,“schemaVersion”: 39, “tags”: , “timezone”: “”,“version”:11}, “folderUid” : “the folder when i need to save my existing dashboard”}’ http://admin:admin@127.0.0.1:3000/api/dashboards/db
The dashboard created is always a new dashboard and not the one with the data
thx a lot for you re help
POST request on that endpoint will result in creation of a new dashboard, you’re just setting the uid of the dashboard to the old one, not populating it with data. I’m not sure you can actually move the dashboards by API in one request. What I would do would be to GET the dashboard (first request), create the dashboard in the new folder (POST - second request) and lastly remove the old dashboard (third request).
A few things to notice:
- from the GET request, you’ll get something like:
{
"dashboard": {
...
},
"meta": {
...
"folderUid": "l3KqBxCMz"
}
}
whereas POST request requires something like:
{
"dashboard": {...}, // dashboard field from GET request,
"folderUid": {...} // folderUid field from meta field from GET request
}
(I’ve once cut out people from basically all of their dashboard because I failed to notice that ).
- I’m not sure about having two dashboards with the same UID (even in other folders) - I don’t know If the DELETE request would delete both, the new, or the old (?), so that’s something you should look out for.
Hope that helps