Azure devops boards REST API - move ticket between columns

Viewed 778

I'm testing out the Azure Boards rest API. I can currently create, delete and get items successfully, however I can't seem to move them between columns.

This is my request https://{{AzureBoardsToken}}@{{AzureBoardsPath}}/_apis/wit/workitems/8907?api-version=6.0-preview.3

with a payload of

[
  {
    "op": "move",
    "path": "{no idea what to put here}",
    "from": "{no idea what to put here}",
    "value": "{not sure if this is relevant for this operation}"
  }
]

I don't find the documentation particularly useful as it assumes you know what those properties mean and where to get them.

Any help would be highly appreciated! The idea is to then integrate it in nodejs

2 Answers

Solution 1

To move workitem to another column you have to change "WEF_{id}_Kanban.Column" field.

Use PATCH to update your workitem with body:

[
    {
        "op": "replace",
        "path": "/fields/WEF_F9DCD9224F6E466499435017DB7D2D07_Kanban.Column",
        "value": "<column name>"
    }
]

Solution 2

To move workitem to another column you have to change it "state". This only works if you assigned that state to the column.

Use PATCH to update your workitem with body:

[
    {
        "op": "replace",
        "path": "/fields/System.State",
        "value": "<column name>"
    }
]

doc: https://docs.microsoft.com/en-us/rest/api/azure/devops/wit/work%20items/update?view=azure-devops-rest-6.0

EDIT (Adding new state):

Go to organization settings -> Process -> choose your workflow -> choose item type -> states -> new state (Add "In progress" here)

enter image description here

Tutorial: https://docs.microsoft.com/en-us/azure/devops/organizations/settings/work/customize-process-workflow?view=azure-devops#add-a-workflow-state

Then go to column setting on Kanban Board and associate new state with column

enter image description here

Tutorial: https://docs.microsoft.com/en-us/azure/devops/boards/boards/add-columns?view=azure-devops#update-kanban-column-to-state-mappings

After that try using API REST to change state, it should work

To alter the System.State of a task I had to alter the System.Reason as well. For some reason the two fields are connected and both changes are necessary to trigger a transition from one column to the other.

For example to change a task from the state To Do to In Progress use the Work Items - Update REST API with the following request body:

[
  {
    "op": "replace",
    "path": "/fields/System.State",
    "value": "In Progress"
  },
  {
    "op": "replace",
    "path": "/fields/System.Reason",
    "value": "Work started"
  }
]
Related