restCall
  • 08 Jun 2023
  • Dark
    Light
  • PDF

restCall

  • Dark
    Light
  • PDF

Article summary

restCall Task 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.

Note:

Refer to Proxy Settings for Pre-builts if the restCall needs to access an endpoint on the other side of a proxy.

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.

Example 1

In this IAP example, a simple "GET" call is executed.

  • The uri value is statically set to https://deckofcardsapi.com/api/deck/new/shuffle/?.

  • The verb value is statically set to GET.

  • The API being referenced is a very simplistic API and does not require any input for the variables user, password, headers, or body.

  • The responseHeaders value has been set to "True".

    restCall-ex01

  • The outgoing response will contain information relevant to the REST call. In this case, a deck_id, the number of cards remaining in the deck, and a value to indicate if the virtual deck was shuffled. Because the responseHeaders value 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 uri is statically set to https://petstore.swagger.io/v2/pet.

  • The verb is statically set to POST.

  • The API being referenced does not require an input value for user, password, or headers.

  • For this specific REST call, a reference variable for the body is 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 responseHeaders value is set to "False".

    restCall-ex02

  • In this REST call, the outgoing response object will contain nearly identical information as posted in the body. In this case, the output response is 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 the response will vary depending on the REST call and API provider.

Example 3

In this IAP example, a simple "GET" call is executed.

  • The uri is statically set to https://api.sunrise-sunset.org/json?lat=33.791570&lng=-84.389510&date=today.

  • The verb is statically set to GET.

  • This particular REST call does not require values for user, password, or body.

  • A variable for the headers is also not required; however, for the sake of this example, let's specify the following headers value:

    {
        "Content-Type": "application/json; charset=utf-8"
    }
    
  • The responseHeaders variable is set to "True".

    restCall-ex03

  • The outgoing response object 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"
    }
    

Was this article helpful?

What's Next
Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.