Rakesh Suryawanshi
Rakesh Suryawanshi

Reputation: 520

How can I tirgger vsts rest API for a release with auto approver?

We are automating the release trigger procedure. in one of our scenarios we need to trigger release though rest api's, and triggering release should be auto approve.

is there a way I can auto approve the release, do we have any rest api which performs approval.

considering the account which is triggering it got permission to approve the release.

Upvotes: 0

Views: 352

Answers (2)

Rakesh Suryawanshi
Rakesh Suryawanshi

Reputation: 520

I have tried this

$deployUrl = "https://vsrm.dev.azure.com/{ornizationName}/{projectName}/_apis/release/approvals/{approvalid}?api-version=5.1"

        $body = @{
            status       = "approved"
            comments        = "go !"
        } | ConvertTo-Json -Depth 4
        "body= $body"

        $verb= "Patch"
        Invoke-RestMethod -Method $verb -ContentType "application/json" -Uri $deployUrl -Headers @{Authorization=("Basic {0}" -f $base64authinfo)} -Body $body

Upvotes: 0

Hugh Lin
Hugh Lin

Reputation: 19451

How can I tirgger vsts rest API for a release with auto approver?

For this issue ,you can use Approvals - Update rest api :

PATCH https://vsrm.dev.azure.com/{organization}/{project}/_apis/release/approvals/{approvalId}?api-version=5.1

Sample request body:

{
  "status": "approved",
  "comments": "go!"
}

If you want to performs approval,you only need to set status to approved.

With Approvals - List rest api,you can get approvalId. You can add parameters to the request url according to your needs, and filter out the exact approval to get approvalId .

Below is my test result with postman :

enter image description here

Upvotes: 1

Related Questions