要添加链接了父工作项的工作项,您应该使用 REST API:
POST https://{accountName}.visualstudio.com/{project}/_apis/wit/workitems/${type}?api-version=4.1
应用程序/json-patch+json:
[
{
"op": "add",
"path": "/fields/System.Title",
"from": null,
"value": "title"},
{
"op": "add",
"path": "/relations/-",
"value": {
"rel": "System.LinkTypes.Hierarchy-Reverse",
"url": "URL for the parent work item"
}
}
]
以下是创建任务mytask 的示例,其中链接了父工作项(工作项ID 为184):
POST https://marinaliu.visualstudio.com/Git2/_apis/wit/workitems/$Task?api-version=4.1
应用程序/json-patch+json:
[
{
"op": "add",
"path": "/fields/System.Title",
"from": null,
"value": "mytask"},
{
"op": "add",
"path": "/relations/-",
"value": {
"rel": "System.LinkTypes.Hierarchy-Reverse",
"url": "https://marinaliu.visualstudio.com/f7855e29-6f8d-429d-8c9b-41fd4d7e70a4/_apis/wit/workItems/184"
}
}
]