Hello, over here again!

I want to know if there is any way to deploy widgets from API call.

curl -X POST
http://localhost:5000/api/dashboards
-H “Content-Type: application/json”
-H “Authorization: Key xxxxxxxxxxxxxxxxxxxxxx”
-d ‘{“name”: “DICCIONARIO DE DATOS”}’

Currently I am displaying the dashboard without problems, but I still can’t get something about the widgets!

I have 2 queries for the dashboad, one with a parameter and the other without a parameter.

Technically it’s possible but it’s not documented. The easiest way to learn it is to either examine the source code for the WidgetListResource or to open your browser’s network inspector and spy on the requests as you set up a dashboard manually.

If you’re just making copies of dashboards, you should consider using redash-toolbelt which already has a script to do this automatically.

Great jessie, i will review the 2 ways. Actually the goal is to be able to implement the dashboard from the api call automatically.

If you have something of the json format of the first option, I would really appreciate it.

here I leave the json example to add the widgets for api call

{“options”:{
“parameterMappings”:{},
“isHidden”:false,
“position”:{
“autoHeight”:true,
“sizeX”:3,
“sizeY”:14,
“minSizeX”:2,
“maxSizeX”:6,
“minSizeY”:1,
“maxSizeY”:1000,
“col”:0,
“row”:0}
},
“text”:"",
“width”:1,
“dashboard_id”: id_dashboad,
“visualization_id”:id_vizualitation}

thanks jessie, it is correct the information was there, in WidgetListResource.

1 Like

Glad you found it and thank you for sharing your solution!

Hi,

Could you provide an example on how you used python to create dashboard?
Maybe I am using the wrong headers/url to send the request.

I tried a code based on redash api examples but I got 404 error for these urls:
https://somedomain.com/api/queries

Other user suggested to add “/new” at the end and now I got 500 error:
https://somedomain.com/api/queries/new

Thanks

Sure Sergio, Here I share the example of the api call with curl:

#publicar dashboards

curl -X POST
http://redash.dnslocal.com/api/dashboards
-H “Content-Type: application/json”
-H “Authorization: Key nJJsMXXXXXXXXXXXX”
-d ‘{“name”: “dashboar_name”}’

this is just to create the empty dashboard, then you must use the add widgets, you will find how to do it, in the WidgetListResource section

using that example you can adapt it with python like this:

1 Like

Thank you very much, Juan.
I will try it out.