Azure devops Rest API System.Description

Azure devops RestAPI System.Description

使用 Azure Devops RestAPI 进行一些测试以从 powershell 脚本制作发行说明。 我似乎无法从工作项中取回 System.Description 字段。可能与它是一个 HTML 编辑器字段

这一事实有关

有什么想法吗?

Azure devops RestAPI System.Description

我们可以使用 REST API Work Items - Get Work Item 来获取 workiten 的详细信息:

GET https://dev.azure.com/{organization}/{project}/_apis/wit/workitems/{id}?api-version=6.0

return结果:

注:

  • 是一般的HTML格式化值,例如<div></div> <B></B>.
  • 您需要在描述字段中设置值,否则该字段System.Description不存在。

我的 powershell 测试脚本:

$connectionToken="$(PAT)"
$base64AuthInfo= [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$($connectionToken)"))

$url = "https://dev.azure.com/<YourOrganizationName>/<YourTestProject>/_apis/wit/workItems/184?api-version=6.0" 

$WorkItemInfo = (Invoke-RestMethod -Uri $url -Method Get -UseDefaultCredential -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)})

Write-Host "SystemDescription= $($WorkItemInfo.fields."System.Description" )"

注2:

  • 在获取System.Description的值时,需要在System.Description.
  • 上加上双引号

结果:

椅子和键盘之间存在问题。显然我在查询一个 Bug,它有重现步骤而不是描述。