Dja*_*yCi 3 rest azure-devops azure-devops-rest-api
I\xe2\x80\x99m 构建一个从我们的 Azure DevOps 板获取信息的应用程序。任务之一是获取给定列中存在的所有票证。
\n我\xe2\x80\x99m花了很多时间阅读他们的文档,但所有方法都依赖于你传递你想要返回的IDS,而我\xe2\x80\x99m寻找的是API来告诉我知道给定列中确实存在哪些工作项。
\n在看板列中查找工作项的最简单方法是使用Wiql - 通过 Wiql API 进行查询。其用法与您使用 UI 查询功能查找工作项的方式非常相似。
给定这种板状态下的一些工作项(使用基本模板):
下面是 PowerShell 中的示例:
$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
Run Code Online (Sandbox Code Playgroud)
返回:
id url
-- ---
26 https://dev.azure.com/{organization}/{project}/_apis/wit/workItems/26
Run Code Online (Sandbox Code Playgroud)