1
votes

I am using TFS REST APIs to fetch the workitems info and for other operations. When I use the instructions mentioned on the URL listed below to get the workitem details, JSON which is coming back has all the info related to this workitem but it is missing the "relations" section in it. I have defined parent and child relations for this workitem which I am querying. have tried different querystring options for "expand" such as relations and all.

https://www.visualstudio.com/en-us/docs/integrate/api/wit/work-items#with-links-and-attachments-1

Would really appreciate any guidance on how to fetch the info about related workitems.

1

1 Answers

2
votes

First double check if you are using the correct Rest API with right format, you just need to use get a work item With links and attachments API, sample request:

GET http://xxx:8080/tfs/DefaultCollection/_apis/wit/workitems/4?$expand=relations&api-version=1.0

In the json response, should include relations such as below:

"relations": [
    {
      "rel": "System.LinkTypes.Hierarchy-Reverse",
      "url": "http://xxx:8080/tfs/DefaultCollection/_apis/wit/workItems/7",
      "attributes": {
        "isLocked": false
      }
    },
    {
      "rel": "System.LinkTypes.Hierarchy-Forward",
      "url": "http://xxx:8080/tfs/DefaultCollection/_apis/wit/workItems/10",
      "attributes": {
        "isLocked": false
      }
    }
  ], 

System.LinkTypes.Hierarchy-Reverse stands for parent, and System.LinkTypes.Hierarchy-Forward stands for child.

enter image description here

If you still cannot get the info, go through the links of that specifical work item in the web to see if you have added parent and child relations for this workitem successfully.