假设我正在尝试更新任务组描述。
GET https://dev.azure.com/{organization}/{project}/_apis/distributedtask/taskgroups?api-version=6.0-preview.1
aaabbbcc-abcd-ae12-917d-97f1935b1542
PUT https://dev.azure.com/{organization}/{project}/_apis/distributedtask/taskgroups/aaabbbcc-abcd-ae12-917d-97f1935b1542?api-version=6.0-preview.1
像这样的JSON主体{
"description": "this is the new description",
"id": "aaabbbcc-abcd-ae12-917d-97f1935b1542"
}
但是最后一步不起作用。我会收到以下错误:
{
"$id": "1",
"innerException": null,
"message": "Task group aaabbbcc-abcd-ae12-917d-97f1935b1542 not found.",
"typeName": "Microsoft.TeamFoundation.DistributedTask.WebApi.MetaTaskDefinitionNotFoundException, Microsoft.TeamFoundation.DistributedTask.WebApi",
"typeKey": "MetaTaskDefinitionNotFoundException",
"errorCode": 0,
"eventId": 3000
}
我在做什么错?
GET
API中提供的任务组,并在此处更改描述,然后将其转换为JSON并通过PUT
API发送所有对象。例如-在PowerShell中:
$base64AuthInfo = [Convert]::ToBase64String([Text.Encoding]::ASCII.GetBytes(("{0}:{1}" -f $user,"YOUR-PAT")))
$headers = @{Authorization=("Basic {0}" -f $base64AuthInfo)}
$url = "https://dev.azure.com/{organization}/{project}/_apis/distributedtask/taskgroups?api-version=6.0-preview.1"
$taskGroups= Invoke-RestMethod -Method Get -Uri $url -Headers $headers -ContentType 'application/json'
$taskGroups.value[0].description = "test"
$json = $taskGroups.value[0] | ConvertTo-Json -Depth 10
$response = Invoke-RestMethod -Method Put -Uri $url -Headers $headers -ContentType 'application/json' -Body $json