I'm using TFS REST API and am trying to retrieve work items & their child items by title (parent's title is the parameter). I can't find a way to retrieve these linked items using TFS REST API.
This is what I've tried. First I query for the work items by title:
URI = http://[tfspath]/_apis/wit/wiql?api-version=1.0
query = SELECT * FROM WorkItem WHERE [System.Title] = 'some title'
The above returns me an object WorkItems which has only the ID/URL of the matching work item. Then, I use the returned ID on the query below (lets say the id is 1234):
URI = http://[tfspath]/_apis/wit/workitems/1234?fields=System.Title&api-version=1.0
This returns the title of the item & other fields I might include on the fields list. However, I cannot find a way to include the child items in the returns. I've tried including System.RelatedLinks but this does not change the returned fields. Example:
URI = http://[tfspath]/_apis/wit/workitems/1234?fields=System.Title,System.RelatedLinkCount,System.RelatedLinks&api-version=1.0
Returns
"fields":{"System.RelatedLinkCount":4,"System.Title":"some title"}
Which means there are 4 related links to the work item "some title", but they are not being returned. What am I missing here? How do I get these related links/child items?
Append
&$expand=relations
to the querystring to fetch the links collection of a workitem:To get a work item with all details as well as the links with details, you'll need to use the APIs that are intended for reporting purposes. Due to the possible shear size of the returned document, it will be chunked and you will be given a watermark. You may need to do multiple requests.