Issue with creation of Dashboard via API

Task: It is necessary to create Dashboards with identical widgets for 400+ users using the API.

According to https://www.jetbrains.com/help/youtrack/devportal/HUB-REST-API_Dashboards_Create-New-Dashboard.html

I'm creating a dashboard:
curl -X POST 'https://my.domain.com/hub/api/rest/dashboards?fields=id,name,owner' \
-H 'Authorization: Bearer perm:dmV0YXNzcw==.DjYrNzA=.hf5uWxneWEdVd0AGmmkmYVmLPQ00KA' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-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",
           "title": "",
           "refreshPeriod": 600,
           "youTrack": {
             "id": "ddc3861d-9655-49fe-9ca4-07e9cbc11cba",
             "homeUrl": "https://my.domain.com"
           }
         }
       }
     },
     {
       "id": "youtrack-issues-list",
       "directive": "widget-custom",
       "grid": {
         "width": 2,
         "height": 2,
         "y": 2,
         "x": 0
       },
       "config": {
         "created": "2023-11-16T07:53:39.120Z",
         "customWidgetConfig": {
           "search": "created by: me",
           "title": "",
           "refreshPeriod": 600,
           "youTrack": {
             "id": "ddc3861d-9655-49fe-9ca4-07e9cbc11cba",
             "homeUrl": "https://my.domain.com"
           }
         }
       }
     }
   ]
 },
 "permission": "OWNER",
 "access": "OWNER",
 "favorite": true,
 "ordinal": 2
}'

Result:
{"type":"DashboardJSON","id":"5f1bcc55-e54b-49b8-a428-72f3dcc3e442","name":"4T","owner":{"type":"user","id":"2aaa27e3-4b28-4173-9ae0-ac10a6119166"}}

 

The dashboard is created not for the user with id:230bbea5-78e0-4ce3-be5c-8bea6357f28c

but for user with id: 2aaa27e3-4b28-4173-9ae0-ac10a6119166

This user id corresponds to the user under whom authorization takes place. 

-H 'Authorization: Bearer perm:dmV0YXNzcw==.DjYrNzA=.hf5uWxneWEdVd0AGmmkmYVmLPQ00KA' 

Can you please provide me how to correctly pass the owner parameters when creating a Dashboard?

 "owner": {
   "id": "230bbea5-78e0-4ce3-be5c-8bea6357f28c"
 }
Thanks!!!!

 

0
1 comment
Official comment

Hi,

copying my response from the other thread.

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.

 

 

Please sign in to leave a comment.