WorkItems 更换为新组件后如何恢复旧组件

问题描述 投票:0回答:1

我错误地将不同区域的组件更改为单个组件。我创建了一个组件查询,但没有意识到查询中有错误,并将所有区域的组件更改为单个组件。因此 13K 工作时间得到了更新。

无法手动更改每个项目。有没有办法恢复那些工作项的旧组件?

我探索了返回查询中所有工作项列表的 API。此外,我还探索了检索新旧组件值信息的 API。 我不确定如何才能将所有 13K 工作项改回旧组件的值。

获取工作项历史API: https://dev.azure.com/astera/Centerprise/_apis/wit/workItems/{id}/updates?api-version=5.1

从查询中获取工作项 ID:
https://dev.azure.com/astera/Centerprise/_apis/wit/wiql/{queryid}?api-version=6.0

azure azure-devops devops azure-devops-rest-api
1个回答
0
投票

此操作没有直接的 Rest API,您需要获取 API 的历史记录,然后使用此 更新 API 通过从获取历史记录 API 返回的值来更新组件 请参阅同一文档中的示例部分来更新特定的参数:-

更新工作项API PS代码:-

$PAT = "s3xw5xxxxxx"
$OrgName = "sid24desai0738"  # Update organization name
$ProjectName = "AzureDevops"  # Update project name
$ApiVersion = "7.1-preview.3"
$WorkItemId = "6"

# Construct the URL for the PATCH request
$WorkItemId = "6"  # Replace {id} with the actual ID of the work item
$PatchUrl = "https://dev.azure.com/$OrgName/$ProjectName/_apis/wit/workitems/6?api-version=7.1-preview.3"

# JSON payload for the PATCH request
$PatchBody = @'
[
  {
    "op": "test",
    "path": "/rev",
    "value": 5
  },
  {
    "op": "add",
    "path": "/fields/System.History",
    "value": "Linking to a blog article for context"
  },
  {
    "op": "add",
    "path": "/relations/-",
    "value": {
      "rel": "Hyperlink",
      "url": "http://blogs.msdn.com/b/bharry/archive/2014/05/12/a-new-api-for-visual-studio-online.aspx"
    }
  }
]
'@

# Invoke the PATCH request
Invoke-RestMethod -Uri $PatchUrl -Method Patch -Headers @{
    Authorization = "Basic " + [System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$PAT"))
    "Content-Type" = "application/json-patch+json"
} -Body $PatchBody

输出:-

enter image description here

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.