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

  1. Start Postman.
  2. In the Request Editor, select GET from the methods drop-down list.
  3. Enter the request URL (for example, http://myserver/cda/api/data/v1/approvals).
  4. Click the Params button and enter the following parameter:
    • key= status
    • value=pending

      The system response will only include approval requests with status pending

      Image displaying get params

  5. The CDA REST API requires basic authorization. To enter your credentials click Authorization and select Basic Auth from the drop-down list.
  6. Enter your username and password. This automatically generates an authorization header.
  7. Click Send.

    The response is generated in JSON format.

    Image displaying response

    In this case there are four executions awaiting approval.

  8. Select POST from the methods drop-down list.
  9. 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.
  10. Enter the following text in the raw editor (JSON):

    {

    "status" : "Approved",

    "comment": "OK to start the workflow"

    }

  11. 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
  12. Click Send. This will update the status of the four executions to Approved.

    Image displaying execution status

Congratulations! You have reviewed and approved pending executions in seconds!