Reputation: 1
We already created the code to create a new work item using the rest API of azure devops. What management wants is the same functionality of azure devops when adding new items on the work item menu list (same as "Add link" > "New item..." and a new item will appear below the preview work item). This is so that other departments will not forget where they added the entry.
We already have a new sub-menu name "create sub-task" for users to initiate the creation of backlogs. What management wants is the automatic adding of the newly created items below the parent like with what azure does with "Add link".
They wanted it the same as azure because that was how the other departments were trained when azure devops was open to others for requesting new projects from IT.
Upvotes: 0
Views: 152
Reputation: 13944
When using the REST API to create a new work item, if you want to link this new work item to an existing work item, for example link an existing work item as the parent of the new work item, you can do like as below:
POST https://dev.azure.com/{organization}/{project}/_apis/wit/workitems/${type}?api-version=6.0
2.The request body of the API.
[
{
"op": "add",
"path": "/fields/System.Title",
"value": "Title of the new work item"
},
{
"op": "add",
"path": "/relations/-",
"value": {
"rel": "System.LinkTypes.Hierarchy-Reverse",
// The URL of the existing work item you want the new work item to link.
"url": "https://dev.azure.com/{organization}/{project}/_apis/wit/workItems/{ID}",
"attributes": {
"isLocked": false,
"name": "Parent"
}
}
},
. . .
]
With this way, when you use the REST API to create a new work item, it also will automatically add the specified work item as the parent of the new work item.
For more details, you also can reference the REST API "Work Items - Update".
[UPDATE]
When you do with the option "Add link" > "New item...", it actually will do two things:
Parent-Child
type in your case).The API I posted above does exactly all the things. You can use the API to create the new child work item (Product Backlog Item type in your case) and set its parent as the existing Feature type work item.
Upvotes: 0