Automate dashboard creation via REST API

Hello guys, 

 

Do anyone come cross api that would help to create new dashboard with widgets from existing dashboard or clone a exiting dashboard with its widgets? 

We are creating dashboad per release and we create dashboard then clone the widgets to the new dashboard, it is many manual steps and it is a pain. 

 

Any ideas? 

 

Thanks 

0
5 comments
Official comment

Hello Fayez,

here you can find the API for dashboards: https://www.jetbrains.com/help/hub/HUB-REST-API_Dashboards.html

The widgets are located in the `data` field: https://www.jetbrains.com/help/hub/HUB-REST-API_Dashboards_Create-New-Dashboard.html

Unfortunately, the part of the API concerning widgets is not documented yet, so I can suggest making some requests with the developer tools of your browser open and then imitate the same requests in your code.

Let us know if you need assistance, we'll be happy to help.

Hello, Liubov Dievskaia 

I am creating a new Dashboard according to https://www.jetbrains.com/help/hub/HUB-REST-API_Dashboards_Create-New-Dashboard.html.

Example:
-d '{
 "name": "4T",
 "owner": {
   "id": "230bbea5-78e0-4ce3-be5c-8bea6357f28c"
 },     

"data": {
   "widgets": [
     {
       "id": "youtrack-issues-list",
       "directive": "widget-custom",
       "grid": {
         "width": 2,
         "height": 2,
         "y": 0,
         "x": 2
       },
       "config": {
         "created": "2023-11-13T12:44:47.943Z",
         "customWidgetConfig": {
           "search": "commented by: me",
..............

The Dashboard is being created, but not for the user whose ID I'm passing in "owner": {
   "id": “230bbea5-78e0-4ce3-be5c-8bea6357f28c” }, 

but for the user under which I'm authorizing.
-H 'Authorization: Bearer perm:dmV0YXNzcw==.DjYrNzA=.hf5uWxneWEdVd0AGmmkmYVmLPQ00KA' 
How can I correctly pass the "owner" to create the Dashboard for a specific user?

Thank you!!!
PS: The token is fictional.

0

Hi Vitalii Bilchenko Pe!

This appears to be a bug. We've fixed it in the scope of this public issue: https://youtrack.jetbrains.com/issue/HUB-11578/Cant-create-dashboard-on-behalf-of-other-user. It'll be included in one of the upcoming releases. Feel free to follow the issue to get notified when it's released.

 

0

Hi Sergey Merzlov ,

i am also interesting to automate dashboard creation via REST API.

Currently, I can create a dashboard via REST API. However, I can't find any information on how to create a specific widget in it. 

Are these configurations documented anywhere?

"data": {
   "widgets": [
     {
       "id": "youtrack-issues-list",
       "directive": "widget-custom",
       "grid": {
         "width": 2,
         "height": 2,
         "y": 0,
         "x": 2
       },
       "config": {
         "created": "2023-11-13T12:44:47.943Z",
         "customWidgetConfig": {
           "search": "commented by: me",

 

Thanks in advance!

0

Hi Rbuerkle. This part of the documentation has not had any additions lately, so I would second Liuba's earlier suggestion to try and create a widget on the dashboard in the UI and then check the browser request being made on the frontend. You'll be able to copy that request and make a similar one in your tool or automation.

Some recent changes to note:

  • Dashboards are now part of YouTrack's native API, so YouTrack endpoints should be used (without /hub).
  • If you're looking to add a custom widget, it should be created as a YouTrack app with a widget extension
1

Please sign in to leave a comment.