Purpose
The restCall task is an extremely powerful and flexible task for obtaining and posting data to and from external API data sources. If a specialized adapter is not available, then restCall will likely be the first task you will consider as a way to interact with your external data source.
Potential Use Case
You are developing an automation for employee on-boarding that will automatically create user accounts to your external systems via API. One restCall task can retrieve the list of users from an API accessible data storage. Another restCall task can leverage the creation of user accounts via API calls to the external systems.
Properties
Input and output properties are outlined below.
| Incoming | Type | Description |
|---|---|---|
uri |
String | Required. The URI for the REST call. |
verb |
Enum | Required. The verb for the REST call (options are: DELETE, GET, PATCH, PUT, POST). |
user |
String | If required, the username by which the REST call should be authenticated. |
password |
String | If required, the password by which the REST call should be authenticated. |
headers |
Object | Any custom headers. |
body |
Object | The body for the API call. |
responseHeaders |
Boolean | Required. Indicates if the response should include headers. |
| Outgoing | Type | Description |
|---|---|---|
response |
Object | The response from the REST call. |
Examples
Example 1
In this IAP example, a simple "GET" call is executed.
The
urivalue is statically set tohttps://deckofcardsapi.com/api/deck/new/shuffle/?.The
verbvalue is statically set toGET.The API being referenced is a very simplistic API and does not require any input for the variables
user,password,headers, orbody.The
responseHeadersvalue has been set to "True".
The outgoing
responsewill contain information relevant to the REST call. In this case, adeck_id, the number of cardsremainingin the deck, and a value to indicate if the virtual deck wasshuffled. Because theresponseHeadersvalue was set to "True", the response will include headers data such as content-type, etc.{ "success": true, "deck_id": "tay82vn7nlsu", "remaining": 52, "shuffled": true }
Example 2
In this IAP example, a simple "POST" call is executed.
The
uriis statically set tohttps://petstore.swagger.io/v2/pet.The
verbis statically set toPOST.The API being referenced does not require an input value for
user,password, orheaders.For this specific REST call, a reference variable for the
bodyis required by the API, as shown below.See documentation for petstore.swagger.io.
{ "id": 7777778888889956565, "category": { "id": 0, "name": "Pronghorn" }, "name": "Delores", "photoUrls": [ "http://example.com/images/Pronghorn01.png" ], "tags": [ { "id": 0, "name": "string" } ], "status": "available" }The
responseHeadersvalue is set to "False".
In this REST call, the outgoing
responseobject will contain nearly identical information as posted in thebody. In this case, the outputresponseis confirmation that a pet Pronghorn named "Delores" has been added and is now available for adoption at the mythical pet store. The value provided within theresponsewill vary depending on the REST call and API provider.
Example 3
In this IAP example, a simple "GET" call is executed.
The
uriis statically set tohttps://api.sunrise-sunset.org/json?lat=33.791570&lng=-84.389510&date=today.The
verbis statically set toGET.This particular REST call does not require values for
user,password, orbody.A variable for the
headersis also not required; however, for the sake of this example, let's specify the followingheadersvalue:{ "Content-Type": "application/json; charset=utf-8" }The
responseHeadersvariable is set to "True".
The outgoing
responseobject will contain sunrise and sunset time information for the Itential home office in Atlanta, GA.{ "results": { "sunrise": "10:46:46 AM", "sunset": "12:41:22 AM", "solar_noon": "5:44:04 PM", "day_length": "13:54:36", "civil_twilight_begin": "10:19:17 AM", "civil_twilight_end": "1:08:51 AM", "nautical_twilight_begin": "9:45:55 AM", "nautical_twilight_end": "1:42:14 AM", "astronomical_twilight_begin": "9:10:21 AM", "astronomical_twilight_end": "2:17:48 AM" }, "status": "OK" }