REST API for setting multi select field type in Azure Devops

1.1k Views Asked by At

I have installed following plugin to support multi-value type field in Azure DevOps https://marketplace.visualstudio.com/items?itemName=ms-devlabs.vsts-extensions-multivalue-control#:~:text=Azure%20Devops%20Services,used%20to%20back%20the%20extension.

I am able to set the option for this field by separating using "semicolon". like "A; B; C" I can also see this field in my work item and able to set the values.

I need help with how can I update this multivalue type field through REST API. I want to change the value of the work item which has this multi-value type field through REST API. I have already tried updating them using the following approaches

  1. "A; B"
  2. "A, B"
  3. "[A, B]"
  4. "A;B"
  5. "A,B"

It sets up the value which I am sending using option 4, but it adds those as an extra option though the option already exists with that value. I can see extra spaces on the option which I am sending through REST AP{I, but I have checked my JSON there is no extra space (using option 4).

enter image description here

1

There are 1 best solutions below

2
Vito Liu On BEST ANSWER

I add a new work item field Multivalue control Test and configure Multivalue control

We could get the work item details via the REST API Work Items - Get Work Item:

GET https://dev.azure.com/{organization}/{project}/_apis/wit/workitems/{id}?api-version=6.0

And we could check the value of field Custom.MultivaluecontrolTest

Result:

enter image description here

Then we could update the value via the REST API Work Items - Update to update the value.

PATCH https://dev.azure.com/{organization}/{project}/_apis/wit/workitems/{id}?api-version=6.0

Sample request body:

[
  {
    "op": "test",
    "path": "/rev",
    "value": 7
  },
  {
    "op": "add",
    "path": "/fields/Custom.MultivaluecontrolTest",
    "value": "A;B;C"
  }
]

Result:

enter image description here

The filed value format is A;B;C, same as UI