Search code examples
restapiazure-devopskanban

Choosing VSTS Kanban column when creating an EPIC using the VSTS REST API


I am creating a VSTS Kanban Epic using the REST API. This creates an Epic in the first column of the Kanban.

I want to be able to choose which column it goes into, and also as a second operation be able to move it from column to column using the REST API.

Looking at the list of fields available there is a field 'System.BoardColumn' - is this the correct field to modify to alter the Epic's column?

Thanks


Solution

  • You just need to specify the System.State field value (New, In process and Done) in REST API, then it will go the related column. Since New is the default value for System.State field, it will create in first column if you are not specify the value for System.State.

    Create Epic in second column

    To create an Epic shows in second column (In process) of Epics board, you can use create a work item REST API. Such as below example (create Epic epic3):

    PATCH https://account.visualstudio.com/DefaultCollection/Git2/_apis/wit/workitems/$Epic?api-version=1.0
    

    Content-Type: application/json-patch+json

    [
        {
            "op": "add",
            "path": "/fields/System.Title",
            "value": "epic3"
        },
        {
            "op": "add",
            "path": "/fields/System.State",
            "value": "In Progress"
        }
    ]
    

    Then the epic3 will show in second column:

    enter image description here

    Update an existing Epic from a column to another column

    You just need to replace the value for System.State field by update a field REST API. Such as above example, to move e1 (id=53) from first (New) column to second (IN process) column:

    PATCH https://marinaliu.visualstudio.com/DefaultCollection/_apis/wit/workitems/53?api-version=1.0
    

    Content-Type: application/json-patch+json

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

    Then the work item e1 will show in the second column:

    enter image description here