1. Tasks
  2. API Call

Tasks

API Call

The API Call task is utilized to interact with an external API, enabling the retrieval of data that can be subsequently utilized in subsequent tasks.

Use cases

  • Use to integrate with a Rest API endpoint
  • Use to do a POST request with a body
  • Use to call an API when an action is executed
  • Use to retrieve data from a third party system
  • Use to call an API endpoint that requires a client certificate for authentication.
  • Use to call a webhook on stub.

Basic usage

loading...

Parameters

apiurl

required
string

The endpoint that the task will invoke. If there are any query strings or URL parameters required, they should be specified here.


method

optional
string

The HTTP method to be used for the API call.
For example you can use GET, POST, PUT, DELETE, PATCH. Any HTTP verbs are supported.

Default: GET


headers

optional
object

Any headers that you wish to include in the request. This is where you would typically put the Authorization header.

Default:

loading...

body

optional
object

The body in JSON that you would like to send as part of a PUT or POST request.
The body would typically use variable substitution so that you can replace values with some values from the stub or stubpost.data.


timeout

optional
number

The seconds after which the apicall will time out.

Default: 10

org_credentials

optional
array or object

The org credentials to use for an API call. This requires setting up the org credentials on the Credentials page of Stubber Manage.

Example:

editor
        {
    "tasktype": "apicall",
    "params": {
        "apiurl": "https://dummyjson.com/products/1"
        "org_credentials": {
            "basic": "uuid of org credential"
            "pfx_cert": "uuid of org credential"
        }
    }
}

      
`

Default: 10

Result

loading...

Properties

apiresult.status

integer

The status code indicating the outcome of the API call.


apiresult.statusText

string

A textual description of the result status.


apiresult.body

integer

Contains the body of the API result, providing the actual data retrieved from the external API.

Examples

These are some more complex examples

Request with body

Include a body in your apicall request

loading...

Request with headers

Include custom headers in your apicall request

loading...