Azure DevOps API error: Field state 'Active' not supported when Work Item has been "Removed"

Azure DevOps API error: Field state 'Active' not supported when Work Item has been "Removed"

我有一个状态为“已删除”的特征类型的工作项。在某些情况下尝试将字段状态更新回“活动”时,出现以下错误:

resp = Invoke-RestMethod -Uri $updateUri -Method Patch -ContentType application/json-patch+json -Headers $header -Body $jsonBody
Invoke-RestMethod : {"$id":"1","customProperties":{"FieldReferenceName":null,"FieldStatusFlags":"none","ErrorMessage":"The field 'State' contains the value 'Active' that is not in 
the list of supported values","FieldStatusCode":0,"RuleValidationErrors":[{"fieldReferenceName":"System.State","fieldStatusFlags":"required, hasValues, limitedToValues, 
invalidListValue","errorMessage":"The field 'State' contains the value 'Active' that is not in the list of supported 
values","fieldStatusCode":4194317,"ruleValidationErrors":null}]},"innerException":null,"message":"The field 'State' contains the value 'Active' that is not in the list of supported 
values","typeName":"Microsoft.TeamFoundation.WorkItemTracking.Server.RuleValidationException, 
Microsoft.TeamFoundation.WorkItemTracking.Server","typeKey":"RuleValidationException","errorCode":0,"eventId":3200}
At line:1 char:9
+ $resp = Invoke-RestMethod -Uri $updateUri -Method Patch -ContentType  ...
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
    + FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand

请注意,我的代码可以更新字段。'System.State' 在所有情况下,除非它试图更改“已删除”的工作项。有什么特别的方法吗?

Is there a special way to do this?

恐怕没有这种方法可以做到这一点。

那是因为已经处于Removed状态的workitem无法转换为除New以外的其他状态。

您可以查看文档 Agile workflow states 了解更多详情。

另外,当我们选择Remove某个工作项时,就意味着我们已经放弃了该工作项。如果工作项是re-enabled,它应该return到New的状态。