1
votes

I'm writing an application that retrieves the teams of a given Azure project. After this is done, the user can select the teams he wants in order to see the corresponding work items from Azure Boards. Until now I have managed to use the API and retrieve the boards of the selected Teams, using this resource which returns the id, url and name of the boards, but I cannot seem to find a URL to get the work items associated with those boards.

I understand that an alternative to this is to use WIQL, but I cannot find in the documentation how to do this. The closest thing I've managed to do is a POST request on the https://dev.azure.com/{organization}/{project}/{team}/_apis/wit/wiql?api-version=5.1 URL with the body: {"query": "Select [System.Id], [System.Title], [System.State] From WorkItems Where [System.WorkItemType] = 'Feature'"} but I end up getting all the work items instead of the ones from the project and team I specify in the URL.

What I want to use is a query like: Select [System.Id], [System.Title], [System.State] From WorkItems Where [System.Team] = 'Team1' AND [System.Board] = 'Features'. How can i do this?

1

1 Answers

1
votes

Try adding:

AND [System.AreaPath] UNDER 'ProjectName\Team'

Note: ProjectName\Team will work so long as your area path naming is set up to give each team its own area directly under the project. Go to Project Settings -> Teams -> Select your team -> Iterations and Area Paths -> Areas, then look at the Area assigned to the team. That's what you should use in your WIQL.

To get the Area Path for your team by API, use

https://dev.azure.com/{orgName}/{projectName}/{teamName}/_apis/work/teamsettings/teamfieldvalues?api-version=6.0"

The result of that (at least for me) returned a defaultValue property that contained the Area Path for the team.