Azure DevOps中列出团队下工作项的API请求语法求助
Hey Jennie, let's sort out that API request issue you're facing with fetching work items for a specific team in Azure DevOps! The root problem here is that the Work Item Revisions Reporting API doesn't support adding a team directly to the URL path—your original request breaks the endpoint's expected structure, which is why it isn't returning the right results.
Here are two reliable, working approaches to get team-scoped work items:
1. Use a WIQL Query (Most Flexible)
The Work Item Query Language (WIQL) is the go-to method for filtering work items to a team, since teams are almost always tied to specific Area Paths or Iteration Paths. You'll send a POST request to the WIQL endpoint with a query targeting your team's associated paths.
Example Request
- Method: POST
- URL:
http://dev.azure.com/{organization}/{project}/{team}/_apis/wit/wiql?api-version=7.1-preview.2 - Request Body (JSON):
{ "query": "SELECT [System.Id], [System.Title], [System.State] FROM WorkItems WHERE [System.TeamProject] = @project AND [System.AreaPath] UNDER '{Your-Team-Area-Path}' ORDER BY [System.Id] DESC" }
Quick Notes:
- Replace
{Your-Team-Area-Path}with the actual Area Path linked to your team (e.g.,MyProject/MyTeam). - Adding
/{team}to the URL helps auto-scope the@projectvariable, but you can also hardcode the project name if needed. - Swap
AreaPathforIterationPathin the query if your team organizes work by iterations instead.
2. Filter the Work Item Revisions API Directly
If you want to stick with the workitemrevisions endpoint, you can add an OData-style $filter parameter to narrow results to your team's Area Path.
Corrected Request
GET http://dev.azure.com/{organization}/{project}/_apis/wit/reporting/workitemrevisions?includeLatestOnly=true&$filter=[System.AreaPath] UNDER '{Your-Team-Area-Path}'&api-version=7.1-preview.2
Quick Notes:
- Upgrade your API version to
7.1-preview.2(or a newer stable version)—older versions like5.0-preview.2have limited support for filters. - Don't forget to replace
{Your-Team-Area-Path}with your team's actual Area Path.
Bonus: Fetch Your Team's Area Path Dynamically
If you don't want to hardcode the Area Path, you can pull it automatically via the Team Settings API:
GET http://dev.azure.com/{organization}/{project}/{team}/_apis/work/teamsettings/areapathtoequivalence?api-version=7.1-preview.1
This returns the Area Path(s) linked to your team, which you can plug directly into your work item queries.
That should get you the team-specific work items you need!
内容的提问来源于stack exchange,提问作者Jennie

