Reputation: 1388
Is there a way to get Git Commits that are linked to a work item given only the work item ID?
I'm using PowerShell and this URI to get work items, but I don't see any of the linked commits on the returned object. I also don't see any documentation on how to get these links.
$Results = Invoke-RestMethod -Uri "http://azuredevops/azuredevops/Collection/Project/_apis/wit/workitems?api-version=5.1&ids=1" -Method "GET" -UseDefaultCredentials | Select-Object -ExpandProperty Value
$Results.fields
Upvotes: 5
Views: 3025
Reputation: 19026
You are very close to the correct solution.
The commits which linked to the work item is relation of work item. So, here, you need to specify $expand
in API to get the corresponding commits content.
Get https://dev.azure.com/{org name}/{project name}/_apis/wit/workitems/{id}?$expand=relations&api-version=5.1
Then you would see the commits in relations
part of the response body:
Upvotes: 10