Approving Pending Requests via CDA REST API
Some executions (instances of workflows) may require approval from one or more users to be performed. A user with approval rights can either log on to Automic Continuous Delivery Automation to approve or reject pending approval requests or use a REST client instead. In this scenario we go for the second option and show you how to use Postman to approve pending executions.
Why should I read this scenario?
This scenario will help you learn how to see and approve pending requests via Automic Continuous Delivery Automation REST API.
What will I learn?
- How to see pending approvals via REST.
- How to approve pending requests via REST.
Before you start...
Make sure that the following conditions are met before you start approving pending executions:
- Your CDA system is up and running.
- There are executions awaiting approval. For more information, see Viewing Approval Requests.
- You have a REST client (we will use the free plug-in Postman for this scenario, however, other REST clients can be used too).
To see and approve pending request via Automic Continuous Delivery Automation REST API
- Start Postman.
- In the Request Editor, select GET from the methods drop-down list.
- Enter the request URL (for example, http://myserver/cda/api/data/v1/approvals).
- Click the Params button and enter the following parameter:
- key= status
-
value=pending
The system response will only include approval requests with status pending - The CDA REST API requires basic authorization. To enter your credentials click Authorization and select Basic Auth from the drop-down list.
- Enter your username and password. This automatically generates an authorization header.
-
Click Send.
The response is generated in JSON format.In this case there are four executions awaiting approval.
- Select POST from the methods drop-down list.
- Click the Body radio button and select the raw option. You can select any of the four available body types to construct a request. In this case we will use the raw option to approve the execution status and add a personal comment on the update.
- Enter the following text in the raw editor (JSON):
{
"status" : "Approved",
"comment": "OK to start the workflow"
}
-
Before sending the request, add a new parameter to send the information in JSON format. To do so, click the Params button and enter the following:
- key= Content-Type
- value=application/json
- Click Send. This will update the status of the four executions to Approved.
Congratulations! You have reviewed and approved pending executions in seconds!