Home > OS >  Azure DevOps API error: Field state 'Active' not supported when Work Item has been "R
Azure DevOps API error: Field state 'Active' not supported when Work Item has been "R

Time:02-17

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?

CodePudding user response:

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 enter image description here

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.

  • Related