2
votes

Is there a way to retrieve a list of work items filtered by some field value?

E.G.:

site/tfs/SomeCollection/wit/workitems?Status=Done&asof={datetime}&api-version=1.0

My goal is to use the Rest API to:

  • Go to a specific Iteration (including the current one),
  • get a list of Backlog Items,
  • foreach PBI > Get a list of Done Tasks/Bugs,
  • foreach Done Task/Bug > Get information

Then use that information to do whatever I need.

1

1 Answers

3
votes

You must do that in 2 or more steps :

  1. Use POST https://{account}.visualstudio.com/defaultcollection/[{project}/]_apis/wit/wiql?api-version={version} to get the items using a query with your filter criteria. (https://www.visualstudio.com/en-us/integrate/api/wit/wiql)

    Select [System.Id], From WorkItems Where [System.WorkItemType] = 'Product Backlog Item' AND [System.IterationPath] = 'Iteration 1'

  2. Use GET https://{account}.visualstudio.com/DefaultCollection/_apis/wit/WorkItems?ids=297,299,300&fields=System.Id,System.Links.LinkType,System.WorkItemType,System.Title,System.State&asOf=2014-12-29T20:49:35.357Z&api-version=1.0API to get data for each work item returned from step 1.