Skip to main content
Version: v5.1

REST Connector

Overview

The REST Connector task allows a workflow to directly make an HTTP request to a specified URL. The REST Connector task provides a simple way to integrate external services or APIs without needing a custom worker or microservice.

Sample code

Refer to the sample code below, which shows how to set up a REST Connector task.

{
"_name": "rest_connector_task",
"_type": "REST_CONNECTOR",
"_sequenceno": 1,
"_inputParams": {
"_url": "https://reqres.in/api/users/2",
"_auth": {
"_type": "NoAuth"
},
"_args": {
"headers": {
"x-api-key": "reqres-free-v1"
}
},
"_to": "file"
}
}

Rest Connector parameters

ParameterTypeOptionalDescription
_nameStringNoName of the REST connector task
_typeStringYesEnter REST_CONNECTOR
_sequencenoNumberNoDefines the execution order of the task within a workflow
_inputParamsObjectNoAn object that describes the task's parameters
_urlStringYesThe URL of the request for which data is to be fetched
_authObjectYesAuthentication configuration for the REST request. It takes an object which can have two keys: _type This is a required value. It must be a string and has to be one of the supported authentication schemes. The other key is _params which is on object and is optional. It is based on the required authentication scheme. To see a list of the authentication schemes supported, refer to Supported authentication schemes
_typeStringYesSpecifies the authentication method, for example, NoAuth, Basic, Bearer. Refer to Supported authentication schemes
_argsObjectNoAdditional arguments for the REST request such as headers or query parameters.
_toStringNoDefines the output destination of the response, for example, file.

Supported authentication schemes

Use the _auth parameter to select the required authentication scheme for the REST request.

The REST Connector supports the auth schemes listed below:

Refer to the descriptions below of each auth scheme.

No auth

ParametersDescription
No parameters requiredJust makes an API call without any authentication.

Basic auth

To use the basic auth approach do the following:

  1. Encode username and password as base 64.
  2. Send the encoded string in Authorization header (Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==)
ParametersTypeRequiredDescription
_usernamestringrequiredUsername
_passwordStringrequiredPassword

Example of basic auth:

"_inputParams": {
"_url": "<url>",
"_auth": {
"_type": "BasicAuth",
"_params":{
"_username":"<username>",
"_password":"<password>"
}
},
"to": "json",
"fileName": "<File Name With extension>"
}

Bearer token

To use the bearer token approach:

  • Send the bearer token in Authorization header (Authorization: Bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJleHAiOjE2NTgyODQ2OTMsInVzZXJfbmFtZ..)
ParametersTypeRequiredDescription
_tokenstringrequiredToken type

Example of bearer token:

"_inputParams": {
"_url": "<url>",
"_auth": {
"_type": "BearerToken",
"_params":{
"_token": "<token>"
}
},
"to": "json",
"fileName": "<File Name With extension>"
}

OAuth2 - client credentials

To use the Oauth2 client credentials approach, do the following:

  1. Get token useing client ID and client secret.
  2. Make a HTTP request to the URL with the token as bearer token.
ParametersTypeRequiredDescription
_tokenUrlstringrequiredURL of token
_clientIdstringrequiredClient ID
_clientSecretstringrequiredClient password
_scopestringoptionalRange of request query

Sample code: Example of OAuth2 - client credentials:

"_inputParams": {
"_url": "<url>",
"_auth": {
"_type": "OAuth2ClientCreds",
"_params":{
"_tokenUrl": "<token>",
"_clientId": "<clientId>"
"_clientSecret": "<clientSecret>"
"_scope": "<scope>"
}
},
"to": "json",
"fileName": "<File Name With extension>"
}

OAuth2 - password grant

To use the OAuth2 password grant approach, do the following:

  1. Get the token using the password grant. For more information, see OAuth 2.0 Password grant.
  2. Make a HTTP request to the URL with the token as bearer token.
ParametersTypeRequiredDescription
_tokenUrlstringrequiredURL of token
_clientIdstringrequiredClient ID
_clientSecretstringrequiredClient password
_scopestringoptionalRange of request query
_usernamestringoptionalusername
_passwordstringoptionalpassword

Sample code: Example of OAuth2 - password grant:

"_inputParams": {
"_url": "<url>",
"_auth": {
"_type": "OAuth2PasswordGrant",
"_params":{
"_tokenUrl": "<token>",
"_clientId": "<clientId>"
"_clientSecret": "<clientSecret>"
"_username":"<username>",
"_password":"<password>"
"_scope": "<scope>"
}
},
"to": "json",
"fileName": "<File Name With extension>"
}

OAuth2 - client credentials as JSON body

To use the OAuth2 - client credentials as JSON body approach, do the following:

  1. Get the token using client ID and client secret by passing that information in the request body.
  2. Make a HTTP request to the URL with the token as bearer token.
ParametersTypeRequiredDescription
_tokenUrlstringrequiredURL of token
_clientIdstringrequiredClient ID
_clientSecretstringrequiredClient password
_scopestringoptionalRange of request query

Sample code: Example of OAuth2 - client credentials as JSON body:

"_inputParams": {
"_url": "<url>",
"_auth": {
"_type": "OAuth2ClientCredsJSON",
"_params":{
"_tokenUrl": "<token>",
"_clientId": "<clientId>"
"_clientSecret": "<clientSecret>"
"_scope": "<scope>"
}
},
"to": "json",
"fileName": "<File Name With extension>"
}