问题
I’m building an application that fetches information from our Azure DevOps board. One of the tasks is to get all tickets present in a given column.
I’ve spent quite a lot of time reading through their docs but all the methods rely on you passing the IDS you want to get back, while what I’m looking for is for the API to tell me what work items do exist in a given column.
回答1:
The easiest way to find the work items in a board column would be to use the Wiql - Query by Wiql API. The usage will look very similar to how you just use the UI query functionality to find work items.
Given some work items in this kind of board state (using Basic template):
Example in PowerShell below:
$AzureDevOpsAuthenicationHeader = @{Authorization = 'Basic ' + [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(":$($AzureDevOpsPAT)")) }
$uri = "https://dev.azure.com/{organization}/{project}/{team}/_apis/wit/wiql?api-version=6.0"
$body = @{
"query" = "Select [System.Id], [System.Title], [System.State] From WorkItems Where [System.BoardColumn] = 'Doing'"
} | ConvertTo-Json -Depth 10
Invoke-RestMethod -Method Post -Uri $uri -Headers $AzureDevOpsAuthenicationHeader -Body $body -ContentType 'application/json' |
Select-Object -ExpandProperty workItems
Returns:
id url
-- ---
26 https://dev.azure.com/{organization}/{project}/_apis/wit/workItems/26
来源:https://stackoverflow.com/questions/63587269/how-can-i-find-all-work-items-in-a-given-board-column-via-azure-devops-api