2
votes

I’m trying to use the VSTS Build (2.0) API to retrieve the associated work items and changes for a given build. This build has 100 work items associated with it. When I use the get build details/work items REST method, it will only retrieve 50 items. I’ve tried the following: https://my-account.visualstudio.com/DefaultCollection/MyProject/_apis/build/builds/7/workitems?api-version=2.0 // Without specifying a maximum number of work items -> it returns 50 https://my-account.visualstudio.com/DefaultCollection/MyProject/_apis/build/builds/7/workitems?api-version=2.0&$top=100 // specifying a maximum of 100 items -> it returns 50 https://my-account.visualstudio.com/DefaultCollection/MyProject/_apis/build/builds/7/workitems?api-version=2.0&$top=0 // specifying a top of 0, hoping that means all -> it returns none https://my-account.visualstudio.com/DefaultCollection/MyProject/_apis/build/builds/7/workitems?api-version=2.0&$top=-1 // specifying a top of -1, hoping that means all -> it returns none https://my-account.visualstudio.com/DefaultCollection/MyProject/_apis/build/builds/7/workitems?api-version=2.0&$top=50&$skip=50 // hoping to get the next 50 items (51..100) -> it returns the same first 50

Any idea how I can get the complete list of associated work items? And associated changes, for that matter?

1

1 Answers

2
votes

You can't do this through a single Rest API(https://www.visualstudio.com/en-us/docs/integrate/api/build/builds#work-items) for now.

I had a similar experience and finally found this issue: TFS 2017 Update1: Associated Work Items for a build has a limit of 50 work items. However the issue still Under Consideration without any udpate.

Eventually, as a workaround, I get all related changesets for a single build and retrieve all related work items for each changesets.

Perform effectively but not efficiently.