Running workflows through API calls

Use an external service to trigger workflows with the REST API calls by configuring HTTP methods, endpoints, authentication, headers, and request bodies.

About this task

Note: To run workflows through API requests, you must use an external service that can send HTTP requests. In the following example, Postman is used as an external client.

Procedure

  1. Open Postman and select the appropriate HTTP method based on the workflow action.
  2. Access the API Details page and copy the API endpoint.
  3. Paste the API endpoint in the Request URL field in Postman.
  4. Append the resource and method to the API endpoint.
  5. Click the Resources and Methods tab to view available options. A list of resources and methods that are associated with the API appears.
  6. Copy the resource and method.
  7. Paste the resource and method to the API endpoint in the Request URL field in Postman.
  8. Next, configure the settings for API request in Postman. Click the Authorization tab. Set the Authorization type to API Key, use X-INSTANCE-API-KEY as the Key name, and provide the Key Value that is copied when the API key is created by using the SaaS Console. Set the value in the Add to field as Header.
    For detailed steps on how to create API keys and Service IDs in the SaaS Console, see Granting access through service IDs and API keys from the IBM SaaS console.
  9. Add relevant headers associated with this API request.
  10. Click the Headers tab, and set Content-Type to application/json.
  11. Add the rest of the headers as key-value pairs.
    Note: Currently the REST API builder supports only the application/json content type.
  12. Specify the data that you want to send in the Body of the API request in the JSON format.
  13. Click the Body tab and select the raw format. In the example, the name of the card to be created is sent in the API request body. Check that the payload keys that are sent in the request body are the same as the webhook payload keys added earlier.
    Note: HTTP methods - GET retrieves data and DELETE removes the specified resource. Hence, the Body field for these methods must remain blank. The HTTP method - POST , PUT, and PATCH make certain modifications in the specified resource and must have values in the Body field.
  14. Click Send to send an API request.
    The workflow that is associated with the API request is started and on a successful run, you can view the output of the workflow in the Postman interface.
    Note: Whenever a workflow is started from the REST API, the Path parameter that is provided in the REST API URL is included to the body of the request, as there is no Pathparameter option in workflow.