Search code examples
python-3.xazure-devopsazure-devops-rest-api

Create new top-level backlog in Azure Devops through Azure DevOps REST API


I’ve been writing a Python script that uses Azure DevOps REST API to automate some steps in regards to the creation of a organization in Azure DevOps.

One of the steps includes creating four new backlog levels, but I don’t seem to find any endpoint in the API that could help me with that task.

For reference, I’m trying to reproduce the steps shown here:

https://learn.microsoft.com/en-us/azure/devops/organizations/settings/work/customize-process-backlogs-boards?view=azure-devops

More specifically, in the “Add a portfolio backlog” part of the document.

Can anybody help me? I'm editing through repl.it and using the requests library, if that's helpful.


Solution

  • One of the steps includes creating four new backlog levels, but I don’t seem to find any endpoint in the API that could help me with that task.

    To meet your requirement, you can use the following Rest API:Behaviors - Create to add the New Backlog levels.

    Rest API:

    POST https://dev.azure.com/{organization}/_apis/work/processes/{processId}/behaviors?api-version=7.1-preview.2
    

    Request Body:

    {
        "inherits":"System.PortfolioBacklogBehavior",
        "name":"backloglevelname",
        "referenceName":null,
        "color": "009CDD"
    }
    

    Then it will create new backlog level in Process. You can record the referenceName in the Rest API response

    Result:

    enter image description here

    If you need to add the work item type to the new Backlog level, you can use the following Rest API:

    Rest API:

    POST https://dev.azure.com/{Organization}/_apis/work/processes/{ProcessID}/workItemTypesBehaviors/{processname.workitemtype}/behaviors?api-version=5.0
    

    Request Body:

    {"behavior":{"id":"referenceName"},"isDefault":true}
    

    Refer to the doc to get the Process ID.