Error uploading dashboard to grafana.com through API

Hi! I’m trying to upload a dashboard to grafana.com but I’m getting an error, this is the command i use:

curl -X POST -H "Authorization: Bearer $GRAFANA_API_KEY" -H "Content-Type: application/json" -d @dashboard.json https://grafana.com/api/dashboards/db

and this is the response i get:

{
  "code": "InvalidArgument",
  "message": "Unexpected parameter: dashboard"
}

The format of the son file follows the schema described here https://grafana.com/docs/grafana/latest/http_api/dashboard/

Any help is very appreciated, thanks!

That is dashboard model for dashboard API. But you need different model, which you can get from the UI only (export dashboard from your browser). You can compare these 2 models and you will see difference.

Thanks a lot for your response @jangaraj i also tried with the exported model and got a similar error:

{
  "code": "InvalidArgument",
  "message": "Unexpected parameter: __inputs"
}

How did you know that URL https://grafana.com/api/dashboards/db is for dashboard uploading? IMHO you are mixing Grafana (product) HTTP API with Grafana.com (web portal) API.

Why you don’t use Grafana.com UI, when you want to publish your dashboard?

Yeah, that is possible, I verified that a GET to https://grafana.com/api/dashboards gives me a json with the complete list of dashboards, same as the dashboards list in the browser. Also, that queries to /api/dashboards require proper authentication and the response looks meaningful. But I haven’t found anywhere saying that this is possible, it would be great if someone in the community can clarify.

My goal is to host the dashboard json on a repo and upload it in the final stage of the CI/CD pipeline.

1 Like

Hi,
I’m also interested in the same process.
We want to publish our dashboard after a CICD process. (internal review, archive and public publication to grafana hub and so on…).
I still didn’t find any information about the url and the method to do this while there are api keys…
Thanks,
Thierry

Thanks