8

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 !

2 Answers 2

11

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

Sign up to request clarification or add additional context in comments.

3 Comments

damn.. i was placing "overwrite": true in the meta part, not at the top level... is there a way to put this line automatically in the json model ? i'm placing it manually after export and this is not very convenient...
@user2462699 I use python, where it is piece of cake. You may try to play with jq./sed/...
@JanGaraj can you share any python code snippet/example for this? would be great if it uses grafanlib.
4

Increment version field one time or several.

 "uid": "hDfaY-fGk",
  "version": 20            <-this one. Make it 21, 22, 23
}

2 Comments

The right answer.
Doesn't appear to work for me. Still the same message.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.