如何通过Azure DevOps API在给定的板列中找到所有工作项? [英] How can I find all work items in a given board column via Azure DevOps API?

查看:37
本文介绍了如何通过Azure DevOps API在给定的板列中找到所有工作项?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在构建一个应用程序,该应用程序可从Azure DevOps板中获取信息.任务之一是让所有票证显示在给定的列中.

我已经花了很多时间阅读他们的文档,但是所有方法都依赖于您传递要获取的IDS,而我正在寻找的是API来告诉我哪些工作项在做什么存在于给定的列中.

解决方案

在木板列中查找工作项的最简单方法是使用

下面的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 = @ {查询"=从其中[System.BoardColumn] ='Doing'的工作项中选择[System.Id],[System.Title],[System.State].} |ConvertTo-Json-深度10Invoke-RestMethod-方法发布-Uri $ uri -Headers $ AzureDevOpsAuthenicationHeader -Body $ body -ContentType'application/json'|选择对象-ExpandProperty工作项 

返回:

  id网址--26 https://dev.azure.com/{organization}/{project}/_apis/wit/workItems/26 

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.

解决方案

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

这篇关于如何通过Azure DevOps API在给定的板列中找到所有工作项?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆