When using an API call that returns an array, you can save the data to tables set up via the Response Map section of the API Manager. This article discusses this feature in more detail.
Table of Contents
- Prerequisites
- Introduction
- Handling Array Data Returned by API Calls
- Sample Usage
- Using Mapped Tables in Workflows
Prerequisites
Before going through this article, it is recommended that you should already be familiar with Using the AUTTO API Manager.
If the API for the application you are connecting to uses OAuth, you may also want to read API Manager Integrations.
Introduction
Workflows created in AUTTO can integrate with other applications through the Integrations option on the Main Menu. AUTTO directly integrates with the following applications:
From the Integrations option, you can also set up API Manager Integrations to ease connection of your workflows with applications that you connect to using APIs. For more information, see API Manager Integrations.
You can also use the API Manager to create GET, POST, PUT, and PATCH requests to APIs that do not directly integrate with AUTTO. For more information, see Using the AUTTO API Manager.
NOTE: Familiarity with web applications development is needed when working with APIs.
Handling Array Data Returned by API Calls
Data returned by your API calls are mapped to AUTTO [square bracket] types set up on the Response Map section of the API Manager. If you are expecting your API call to return an array, you can use a Table data type to handle the array. Once set up, the data from the array can then be saved to the Table.
Sample Usage
Consider a scenario where you want to choose a company's old name from a list returned by an API call.
NOTE: It is assumed that you have set up your API call already following the instructions in Using the AUTTO API Manager and that you are now ready to map the responses from the API call.
A GET Call to the UK Companies Database returns this array as part of the data:
"previous_company_names": [
{
"name": "DOE & DOE LLP",
"ceased_on": "2013-08-02",
"effective_from": "2012-11-30"
},
{
"effective_from": "2004-05-24",
"name": "DOE LLP",
"ceased_on": "2012-11-30"
}
The array is seen in table format below.
Name | Effective From | Ceased On |
DOE & DOE LLP | 2012-11-30 | 2013-08-02 |
DOE LLP | 2004-05-24 | 2012-11-30 |
To set this up in the API Manager:
- On the API Manager, click the Response Map button.
- Click Add Response, then select Table from the list of data types.
- A Table API response is then added to the list of responses on the Response Map. To set up the API response, click the down arrow to its right.
- Enter a property name and JSON key for the response, adding an optional description if needed.
- To map the Name table column in the API response, click the Add Column button, select Text as the column data type, then enter the property name and JSON key for the column, adding an optional description if needed.
- Click Done.
NOTE: Although we are not using regular expressions (Regex) for the columns in this example, if you want to use Regex, click the Advanced Options button, enable Regular Expressions, then enter the Regex that will be used to extract the retrieved data from the API. AUTTO supports the STRING.PROTOTYPE.MATCH functionality with Regex. Upon mapping, the resulting value from the API response will be matched and mapped to a [square_bracket] based on the Regexp. For more information on Regex, click here.
From Advanced Options, you can also set a default value that will be used if the API fails to provide a response. These should all be done prior to saving the column.
- To map the Effective From and Ceased On table columns in the API response, repeat Steps 5-7 twice, selecting Date as the column data type both times, entering their property names and JSON keys, and selecting your timezone and input format.
NOTE: Just like with the Text column we set up earlier, you can also set other column data types to use Regex from Advanced Options. You can also set default values for other column data types, if needed.
- Click Done. The complete Table API response is shown below.
NOTE: You can also use Regex and/or set up default for the table as a whole from the Table data type's Advanced Options.
Using Mapped Tables in Workflows
You can bring tables into a workflow using the Get Data and Send Data actions, where an Admin user can name the table. For more information, see Get Data Action and Send Data Action.
API calls with TABLE data types mapped to external API arrays appear in the Get Data (for GET API calls) and Send Data actions (for POST, PUT, and PATCH API calls).
Once a call is selected, it should provide the required fields. In a Get Data Action, this means a mandatory Square_bracket name for tables from the API call used in the workflow. In a Send Data Action, this means square bracket names for the variables/data to be sent to another external API or system, and square_bracket names for the data to be sent to the workflow from the same source.
NOTE: PATCH calls are for partial updates to a resource. That is, they only send the fields that have been updated. When sending a PATCH request, the only response will be that the call has been successful. You can use a GET after a PATCH to check that the fields have been updated.
After a Table from an API response has been given a square_bracket name, it becomes available for use like any other table in a workflow. The same goes for table columns and cells, with square_bracket names for these columns generated identically to any other table in the following format:
- [TableName.ColumnNamefromAPICall]
After naming a table, an Admin user can also pull the table into a LookUp Question and allow users to pick one of the names in the Table before moving the workflow forward. For more information, see Lookup Questions.
Comments
0 comments
Article is closed for comments.