Reputation: 1
I am trying to add widgets to the standard(default) overview dashboard using the rest API (PAT). basically I want to update default overview dashboard and add widgets to it. while doing this, REST API call is adding new overview dashboard instead of updating existing overview dashboard
**Documentation **: https://learn.microsoft.com/en-us/rest/api/azure/devops/dashboard/widgets/create?view=azure-devops-rest-7.1&tabs=HTTP
Method: PUT/PATCH URL : https://dev.azure.com/TenantN/DemoProject/_apis/dashboard/dashboards/e63247c4-b069-4bfe-ad1f-6fe609579629?api-version=7.1-preview.2
Body JSON:
{
"position": 2,
"name": "Individual 2",
"description": "TestDB3",
"eTag": "3",
"refreshInterval": 0,
"dashboardScope": "project",
"widgets": {
"name": "TestSQ",
"position": {
"row": 1,
"column": 1
},
"size": {
"rowSpan": 1,
"columnSpan": 1
},
"settings": "",
"settingsVersion": {
"major": 1,
"minor": 0,
"patch": 0
},
"contributionId": "ms.vss-dashboards-web.Microsoft.VisualStudioOnline.Dashboards.QueryScalarWidget"
}
}
The proper way to update existing overview dashboard using rest API
Upvotes: 0
Views: 320
Reputation: 6487
You can add a widget in an existing dashboard in the following way-
I have used the below URL to add widget in an existing dashboard-
POST https://dev.azure.com/{organization}/{project}/_apis/dashboard/dashboards/{dashboardId}/widgets?api-version=7.1-preview.2
Request Body
{
"name": "Other Links",
"position": {
"row": 1,
"column": 1
},
"size": {
"rowSpan": 1,
"columnSpan": 2
},
"settings": null,
"settingsVersion": {
"major": 1,
"minor": 0,
"patch": 0
},
"dashboard": {
"eTag": "18"
},
"contributionId": "ms.vss-dashboards-web.Microsoft.VisualStudioOnline.Dashboards.OtherLinksWidget"
}
Output:
Dashboard:
Update
We can add widgets in Team dashboard as well in the following way-
Get Request
To check if the Team dashboard is present in the given Team.
URL-
GET https://dev.azure.com/{organization}/{project}/{team}/_apis/dashboard/dashboards/{dashboardId}?api-version=7.1-preview.3
Use the above Team dashboard Id and the same team name while making POST request.
URL-
POST https://dev.azure.com/{organization}/{project}/{team}/_apis/dashboard/dashboards/{dashboardId}/widgets?api-version=7.1-preview.2
Upvotes: 0