Okta Workflows how-to guides are questions and answers from weekly community office hours, MacAdmins Workflows Slack channel, and other places.
Read all the other how-to guides ⤵️
All Okta Workflows How-To Guides
Okta Workflows Staff for Okta Workflows ・ Aug 23 ・ 1 min read
On to the question.
How to call an API when it’s not available from an existing card (connection)?
You will learn about 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)
Using an available Workflows app connection
Workflows has over 50 out-of-the-box connections to various external services:
and 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 Google Calendar. What’s 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 searching for events using 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 you need to create a new customer, you use the Shopify – Create Customer card:
Now you want to list the customers you have. When you look at the app actions, no such action is available. You can 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, you enter the Relative URL. You you don’t need to enter the host or the authentication information as it leverages the existing connection to Shopify. You can 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:
You can confirm this by calling the /admin/api/2022-07/customers/count.json
endpoint to return the count of customers:
Calling a custom API endpoint
You want to use ShipEngine API to validate physical addresses. Workflows doesn’t have a connector for ShipEngine. For such cases you can use the API Connector card which allows to call any external API.
When using the API Connector card, you need to enter all the information to call a particular API endpoint. Usually you would go to API’s documentation to learn how to setup a call.
Using API Connector – Post card for ShipEngine’s Validate an Address endpoint you need 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:
One tip I want to share. If you use ShipEngine’s API often and in different flows, you can setup a connection which holds the authentication information for a particular API. With ShipEngine API, put the API-Key header there:
You no longer need to provide the API key in Headers :
This guide showed how to use a Custom API Action card and API Connection card to call APIs when they (APIs) are not available as part of the out-of-the-box connector.
📺 Short how-to Workflows videos to help you become a better automation builder.
🔮 A collection of helpful Workflows tips.
Top comments (0)