如何将工作项作为子项添加到父项? [英] How to add work item as child to parent?

查看:64
本文介绍了如何将工作项作为子项添加到父项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经能够通过VSTS REST API找到有关创建工作项的文档,但是,我却找不到任何创建工作项并将其链接到父工作项的东西.

I've been able to find documentation on creating work items via the VSTS REST API, however, I haven't been able to find anything creating a work item and linking it to a Parent work item.

四处搜寻,我看到一些有关 System.LinkTypes.Hierarchy-Reverse 的链接,但是没有关于它如何工作的API参考,也没有关于如何将工作项链接到父工作的API参考.商品编号.链接此处

Searching around, I've seen some links regarding a System.LinkTypes.Hierarchy-Reverse, but no API reference on how it works, or how it might link a work item to a parent work item id. Link here

推荐答案

要添加链接了父级工作项的工作项,您应该使用REST API,如下所示:

To add a work item with parent work item linked, you should use the REST API as:

POST https://{accountName}.visualstudio.com/{project}/_apis/wit/workitems/${type}?api-version=4.1

application/json-patch + json:

application/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"
    }
    }

]

下面是创建链接了父工作项目(工作项目ID为 184 )的任务 mytask 的示例:

Below is the example to create a task mytask with parent work item (work item id is 184) linked:

POST https://marinaliu.visualstudio.com/Git2/_apis/wit/workitems/$Task?api-version=4.1

application/json-patch + json:

application/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"
    }
    }

]

这篇关于如何将工作项作为子项添加到父项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆