This article describes how to call an API when it is unavailable from an existing card (connection).
There are three ways to call in API:
- Using an available Workflows app connection
- Using a Workflows app connection with a custom API endpoint
- Calling custom API endpoint (when no card is available)
- Okta Workflows
Using an available Workflows app connection
Workflows has over 50 out-of-the-box connections to various external services:
Each connection supports a number of actions. This is a partial list of actions supported by the Google Calendar card:
Behind the scenes, each action is an API call to the Google Calendar API. What is nice, of course, the Google Calendar card does the API call setup automatically. It knows the API endpoint, the headers, the (query) parameters, and anything else needed. Here is an example of searching for events using the Google Calendar – Search card:
Leveraging a Workflows app connection with a custom API endpoint
Looking at another app connection, Shopify, it has the following actions:
When a new customer needs to be created, use the Shopify – Create Customer card:
Next, list the available customers. When looking at the app actions, no such action is available. It is possible to use the Custom API Connection card to call a Shopify API endpoint and leverage an existing connection to Shopify.
Using the Shopify – Custom API Action card, enter the Relative URL. There is no need to enter the host or the authentication information, as it leverages the existing connection to Shopify. It is possible to enter Query or additional Headers if a particular endpoint requires that.
Testing the Customer API Action card with /admin/api/2022-01/customers.json endpoint results in listing four customers:
Confirm this by calling the /admin/api/2022-07/customers/count.json endpoint to return the count of customers:
Calling a custom API endpoint
It is recommended to use the ShipEngine API to validate physical addresses. Workflows does not have a connector for ShipEngine. For such cases, use the API Connector card to call any external API.
When using the API Connector card, it is necessary to enter all the information to call a particular API endpoint. Usually, go to API’s documentation to learn how to set up a call.
When using the API Connector – Post card for ShipEngine’s Validate an Address endpoint, it is necessary to provide:
- URL
- Headers (for API key)
- Body (a list of addresses to validate)
When the API call is successful, the result says an address was verified and also returns a matched address:
NOTE: If using ShipEngine’s API often and in different flows, it is possible to setup a connection that holds the authentication information for a particular API. With ShipEngine API, put the API-Key header there:
Is no longer needed to provide the API key in Headers:
This guide showed how to use the Custom API Action card and the API Connection card to call APIs when they (APIs) are not available as part of the out-of-the-box connect.
Related References
