【问题标题】:Azure DevOps Services REST API - Batch Update of Work ItemsAzure DevOps Services REST API - 工作项的批量更新
【发布时间】:2021-12-31 21:36:29
【问题描述】:

我正在寻找通过 ADO REST API 批量更新工作项的示例。

本文档包含示例链接,这些链接似乎不起作用: https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/workitembatchupdate?view=azure-devops-rest-6.0

【问题讨论】:

  • 您介意分享相关代码并详细说明您遇到的错误吗?

标签: azure-devops azure-devops-rest-api azure-devops-services


【解决方案1】:

您可以参考旧版文档:Work Item Batch Update

另一种方法是编写脚本以循环调用Work Items - 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)}

【讨论】:

    猜你喜欢
    • 2021-05-06
    • 1970-01-01
    • 2020-11-11
    • 1970-01-01
    • 2020-12-18
    • 2021-02-22
    • 2020-07-26
    • 2020-07-06
    • 2020-02-13
    相关资源
    最近更新 更多