neokg
neokg

Reputation: 13

How to create a serviceEndpoint via Azure DevOps REST API with an approver or group of approvers?

I am using the Azure DevOps REST API to create a serviceendpoint/serviceconnection which works fine. I am using the following endpoint: https://learn.microsoft.com/en-us/rest/api/azure/devops/serviceendpoint/endpoints/create?view=azure-devops-rest-6.0&tabs=HTTP

However we would like to specify a group of approvers as you can do via the Azure DevOps portal like shown in the attached image

enter image description here

Project Settings->Serviceconnections-> Approvals and check

Can this be done via the Azure DevOps REST API?

I reviewed the Microsoft docs with regard to Azure DevOps REST API.

Upvotes: 0

Views: 637

Answers (2)

Kevin Lu-MSFT
Kevin Lu-MSFT

Reputation: 35514

Project Settings->Serviceconnections-> Approvals and check Can this be done via the Azure DevOps REST API?

Yes. We can achieve this via Rest API.

You can use the Rest API: Check Configurations - Add to add approvers to service endpoint.

Here is an example:

API URL:

POST https://dev.azure.com/{organization}/{project}/_apis/pipelines/checks/configurations?api-version=7.1-preview.1

Request Body:

{
    "type":{
        "id":"8C6F20A7-A545-4486-9777-F762FAFE0D4D",
        "name":"Approval"
        },
    "settings":{
        "approvers":[{
            "displayName":"UserName",
            "id":"UserID",
            "uniqueName":"emailaddress"
           }],
        "executionOrder":1,
        "minRequiredApprovers":0,
        "requesterCannotBeApprover":false},
    "resource":{
        "type":"endpoint",
        "id":"ServiceEndpointID"
    
        },
    "timeout":43200
}

Result:

enter image description here

Upvotes: 0

Roderick Bant
Roderick Bant

Reputation: 1759

Have not tried this myself, but a little reverse engineering of the Azure DevOps UI leads me to believe there is a generic API object for checks and approvals used by various object types within ADO.

I think Check Configurations API for approvals and checks is what you need. This does use version 7.1 of the API though.

Upvotes: 0

Related Questions