我正在寻找通过 ADO REST API 批量更新工作项的示例。
本文档包含示例链接,这些链接似乎不起作用: https ://docs.microsoft.com/en-us/rest/api/azure/devops/wit/workitembatchupdate?view=azure-devops-rest-6.0
我正在寻找通过 ADO REST API 批量更新工作项的示例。
本文档包含示例链接,这些链接似乎不起作用: https ://docs.microsoft.com/en-us/rest/api/azure/devops/wit/workitembatchupdate?view=azure-devops-rest-6.0
可以参考旧版文档:Work Item Batch Update
另一种方法是编写脚本以循环调用工作项 - 更新REST API 以根据您的要求更新工作项。
下面是一个使用 PowerShell 更新特定工作项的示例,供您参考:
Param(
[string]$baseurl = "https://dev.azure.com/{organization}",
[string]$projectName = "Project",
[string]$workitemid = "124",
[string]$user = "user",
[string]$token = "xxxxx PAT token here"
)
# Base64-encodes the Personal Access Token (PAT) appropriately
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,$token)))
write-host $WorkitemType
function CreateJsonBody
{
$value = @"
[
{
"op": "test",
"path": "/rev",
"value": 2
},
{
"op": "add",
"path": "/fields/System.State",
"value": "New"
}
]
"@
return $value
}
$json = CreateJsonBody
$uri = "$baseurl/$projectName/_apis/wit/workitems/$($workitemid)?api-version=6.0"
Write-Host $uri
$result = Invoke-RestMethod -Uri $uri -Method Patch -Body $json -ContentType "application/json-patch+json" -Headers @{Authorization=("Basic {0}" -f $base64AuthInfo)}