Updating a dashboard via the api resets folderId to 0 (zero)

We’re currently using v 6.3 of the api and I’m having a strange issue when updating dashboards.

We have a lambda function that programatically updates a dashboard via the api (/api/dashboards/uid/{uid}) When it first retrieves the dashboard json the folderId stated in the meta object is correct (it should be 1). When I push the updated json to the api it resets the folder ID to zero, moving my dashboard to the General folder. If I move it back (reset the ID to 1) and update the dashboard again it resets it back again. We currently rely on the folders being correct as if a dashboard is in the wrong folder it can mean alerts being either missed or mis-categorised.

I have inspected the dashboard json object immediately before submitting it and it definitely has the correct ID in, so I’m not sure why it’s doing this. Any help would be really appreciated.

Thanks

I suspect this may have something to do with permissions to that folder?
I am obviously using an api key with admin privs but could it be the permissions on the folder ID I want to use are preventing my updates?

I had the same issue and discussed with Grafana support, it is in fact a bug. Their response below:
I was able to reproduce your problem, but this can be mitigated by defining folderId or folderUid in the API request.

Docs - [Dashboard HTTP API | Grafana Labs]

  • folderId – The id of the folder to save the dashboard in.
  • folderUid – The UID of the folder to save the dashboard in. Overrides the folderId .

With one of these settings set, I was able to update dashboard and leave it in the same folder. You can find folderId/folderUid via API as well.

Docs - [Folder HTTP API | Grafana Labs]