Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to add work item as child to parent?

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.

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

like image 223
Joe Avatar asked May 24 '18 22:05

Joe


People also ask

How do I create a child task in Azure Devops?

Applying Child Tasks Find and select the Create Child Tasks option on the toolbar menu of the parent work item (E.g. Product Backlog Item, User Story, Bug). You should now have children associated with the open work item.

How do I link a user story to a feature in Azure Devops?

From the web portal, open a backlog or query results page, and multi-select the work items you want to add a link to. Open the … context menu of one of the selected work items, choose Add link, and then choose Existing item... or New item....

How to add a work item with parent work item linked?

Link here 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

What is work item parent column in Azure DevOps?

Work Item Parent Column in Azure DevOps. One highly requested, yet simple, feature that has recently been added to Azure DevOps Services is the Work Item Parent Column feature. With this feature, you can now add a column to show the parent of a Work Item in a flat list DevOps query and in your product backlog or sprint backlog.

How do I add or modify work items in a project?

To add or modify work items, you must be granted Stakeholder access or higher. For details, see Stakeholder access quick reference. To view or modify work items, you must have your View work items in this node and Edit work items in this node permissions set to Allow. By default, the Contributors group has this permission set.

How do I add work items to my board?

To add work items and exercise all board features, you must be granted Basic access or higher. To view or modify work items, your View work items in this node and Edit work items in this node permissions set to Allow. By default, the Contributors group has this permission set. To learn more, see Set permissions and access for work tracking.


1 Answers

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:

[
  {
    "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"
    }
    }

]

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:

[
  {
    "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"
    }
    }

]
like image 53
Marina Liu Avatar answered Oct 14 '22 05:10

Marina Liu