Azure DevOps通过REST API获取提交链接到工作项 [英] Azure DevOps get commits linked to a work item via the REST API
本文介绍了Azure DevOps通过REST API获取提交链接到工作项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有没有一种方法可以使Git提交链接到仅提供工作项ID的工作项?
我正在使用PowerShell和
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
解决方案
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:
这篇关于Azure DevOps通过REST API获取提交链接到工作项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文