简体   繁体   中英

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

I have a work item of type feature with a state of "Removed." When trying to update the field state back to "Active" on certain conditions, I'm getting the following error:

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

Note that my code works updating field.'System.State' in all cases except when it's trying to change a "removed" work item. Is there a special way to do this?

Is there a special way to do this?

I am afraid there is no such way to do this.

That is because the workitem that is already in the Removed state cannot be converted to other states except New .

You could check the document Agile workflow states for some more details.

在此处输入图像描述

In addition, when we have chosen to Remove a certain workitem, it means that we have abandoned the workitem. If the workitem is re-enabled, it should return to the state of New .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM