Search code examples
grafanagrafana-api

Grafana overwrite existing dashboard via API


I'm trying to overwrite existing grafana dashboard via API, like this :

curl -X POST -H "Content-Type: application/json" "https://api_key:xxx/api/dashboards/db" -d @test.json

And i'm facing an issue with versioning, cannot overwrite the same dashboard with my json :

{"message":"The dashboard has been changed by someone else","status":"version-mismatch"}⏎

Is there a way to avoid this and force overwriting ?

Thanks !


Solution

  • That really depends what is in your test.json file. I expect correct dashboard model, so you just need to add a few fields to the top level, e.g.:

    "overwrite": true,
    "message": "my saved message, which will be available in the version history"
    

    See API doc - https://grafana.com/docs/grafana/latest/http_api/dashboard/#create-update-dashboard