REST connector
A REST connector allows you to make HTTP requests flexibly and quickly, to get data and pass it to the next step.
For a REST connector, you must pass a URL and an authentication object with one of the following Authentication mechanisms or Auth Schemes:
- No Auth
- Basic Auth
- Bearer Token
- OAuth2 Client Credentials
- OAuth2 Client Credentials as JSON body
- OAuth2 Password Grant
The following code displays a basic REST connector example:
"_actualparams": { "_url": "<url>", "_auth": { "_type": "BasicAuth", "_params":{ "_username": "<username>", "_password": "<password>" } }, "to": "json", "fileName": "<File Name With extension>"}REST connector parameters#
Depending on the authentication you use, your REST connector contains the following parameters:
_url: Required parameter. Enter the request URL that points to the data you want to fetch as a string._auth: Required parameter. Pass an authentication object with the following two keys:_type: Required parameter. Enter one of the following authentication schemes as a string:NoAuthBasicAuthBearerTokenOAuth2ClientCredsOAuth2PasswordGrantOAuth2ClientCredsJSON
For more information, see REST connector code examples for each authentication scheme
_params: Required parameter if you use any authentication scheme, exceptNoAuth. For the value, pass an object that contains the authorization parameters and values for your authentication type and enter their values as strings.Auth scheme Required parameters Required No Auth Basic Auth _usernameYes _passwordYes Bearer Token _tokenYes OAuth2 - Client Credentials _tokenUrlYes _clientIdYes _clientSecretYes _scopeOptional OAuth2 - Password Grant _tokenUrlYes _clientIdYes _clientSecretYes _scopeOptional _usernameYes _passwordYes OAuth2 - Client Credentials As JSON Body _tokenUrlYes _clientIdYes _clientSecretYes _scopeOptional
to: Optional parameter. To define the response format you want to return, for the value, enter one of the following formats:json: Retruns the response as a JSON Objecttext: Returns the response as a stringfile: Stores the response data to a file, uploads the file to the file service, and returns the fileId and fileVersionIdxml2js: Parses inbound XML and returns a JavaScript ObjectFor more information on response examples, seetoparameter responses
fileName: Optional parameter. If value of to field is file then fileName can be specified in the actual params which will be used to store the file in file services with the specified file name.args: Optional parameter. Pass arguments, such as a HTTP request method or header information, to the HTTP request with an_argsobject."_args": { "method": "POST", //If you do not add this parameter, the default is GET. "body": "{\"key\":\"value\"}", "headers": { "Accept": "application/json", "Content-Type": "application/json" } }
REST connector code examples for each authentication scheme#
Refer to the following code examples when you create your REST connector, depending on the authentication scheme you use:
Basic Auth#
"_actualparams": { "_url": "<url>", "_auth": { "_type": "BasicAuth", "_params":{ "_username": "<username>", "_password": "<password>" } }, "to": "json", "fileName": "<File Name With extension>"}BearerToken#
"_actualparams": { "_url": "<url>", "_auth": { "_type": "BearerToken", "_params":{ "_token": "<token>", } }, "to": "json", "fileName": "<File Name With extension>"}OAuth2ClientCreds#
"_actualparams": { "_url": "<url>", "_auth": { "_type": "OAuth2ClientCreds", "_params":{ "_tokenUrl": "<token>", "_clientId": "<clientId>", "_clientSecret": "<clientSecret>", "_scope": "<scope>", } }, "to": "json", "fileName": "<File Name With extension>"}OAuth2PasswordGrant#
"_actualparams": { "_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>"}OAuth2ClientCredsJSON#
"_actualparams": { "_url": "<url>", "_auth": { "_type": "OAuth2ClientCredsJSON", "_params":{ "_tokenUrl": "<token>", "_clientId": "<clientId>", "_clientSecret": "<clientSecret>", "_scope": "<scope>", } }, "to": "json", "fileName": "<File Name With extension>"}to parameter responses#
If you use the optional to parameter, the following objects return in the response if you set the value to either file, json, or text.
file#
{ "rest_conn_result": { "fileId": "<fileId>", "fileVersionId": "<fileVersionId>" }}json#
{ "rest_conn_result": { "userId": 1, "id": 1, "title": "delectus aut autem", "completed": false }}text#
{ "rest_conn_result": "String Response Here"}Xml2js#
Input
<xml> <userId>1</userId> <id>1</id> <title>delectus aut autem</title> <completed>false</completed>Response
{ "rest_conn_result": { "fileId": "<fileId>", "fileVersionId": "<fileVersionId>" }}Creating a rest_connector orchestrator payload#
Create a JSON object with the following properties and the values you want to define:
- _name
- _description
- _namespaces
- _usertype
{ "_name": "Rest Connector", "_description": "Rest Connector Calls", "_namespaces": [ "$current_project._namespaces" ], "_userType": "xlsx_import",}Add a
_paramsproperty with an empty object as its value. In the object, add atasksproperty with an empty array as its value.... "_params": { "tasks": [] }Add your first task to the tasks array as an orchestrator component with the following properties:
_orchcomp: Enterrest_connectoras the value._name: Describe what your task component does._sequenceno: Enter an integer to order the task in the sequence of tasks.... "_params": { "tasks": [ { "_orchcomp": "rest_connector", "_name": "Copy assets relationships from previous version", "_sequenceno": 1, } ] }
In the orchestrator component, add an
_actualparamsproperty with an authentication object as its value. For more information on authentication objects for each authentication scheme, see REST connector code examples for each authentication scheme.... "_params": { "tasks": [ { "_orchcomp": "rest_connector", "_name": "Copy assets relationships from previous version", "_sequenceno": 1, "_actualparams": { "_url": "<url>", "_auth": { "_type": "NoAuth" }, "to": "json" } } ] }Add more orchestrator components to the
tasksarray. Ensure that you order the sequence numbers correctly.
Result: A complete orchestrator with sequenced tasks, including a rest connector and a scripting task. For a complete example, see the following code:
{ "_name": "Rest Connector", "_description": "Rest Connector Calls", "_namespaces": [ "$current_project._namespaces" ], "_userType": "xlsx_import", "_params": { "tasks": [ { "_orchcomp": "rest_connector", "_name": "Get telemetry data from data aggregation platform", "_sequenceno": 1, "_actualparams": { "_url": "http://telemetry.com/api", "_auth": { "_type": "BasicAuth", "_params": { "_username": proj_1.username, "_password": proj_1.username.pwd } }, "to": "json" } } { "_orchcomp": "default_script_target", "_name": "Store telemetry data in the item service", "_sequenceno": 2, "_actualparams": { "userType": "iaf_telem_store", "_scriptName": "storeTelem", } } ] }}IP addresses for Rest Connector calls#
Allowing or denying IP addresses#
To allow or deny specific IP address, you can add the following properties in the config.json file:
ALLOW_IP_ADDRESS_LIST: IP address to allowDENY_IP_ADDRESS_LIST: IP address to deny
Blocked IP addresses for Rest Connector calls#
The following IP addresses are blocked for Rest Connector calls:
| IP address range | Type | Reason for block | Example |
|---|---|---|---|
| 10.0.0.0 – 10.255.255.255 | Private IPv4 | Used for local private networks within an organization that are not routable on the internet | 10.10.10.10 |
| 172.16.0.0 – 172.31.255.255 | Private IPv4 | Used for local private networks within an organization that are not routable on the internet | 172.16.20.30 |
| 192.168.0.0 – 192.168.255.255 | Private IPv4 | Used for local private networks within an organization that are not routable on the internet | 192.168.1.100 |
| 100.64.0.0 – 100.127.255.255 | Shared Address Space | Used for Carrier-Grade NAT (CGN) or large-scale deployments in shared infrastructures | 100.64.10.20 |
| 10.0.0.0 – 10.255.255.255 | Private IPv4 | Used for local private networks within an organization that are not routable on the internet | 10.20.30.40 |
| 100.64.0.0 – 100.127.255.255 | Shared Address Space | Used for Carrier-Grade NAT (CGN) or large-scale deployments in shared infrastructures | 100.65.66.67 |
| 127.0.0.0 – 127.255.255.255 | Loopback | Used to send messages back to the same device, typically for testing purposes | 127.0.0.1 |
| 169.254.0.0 – 169.254.255.255 | Link-local | Link-local addresses are automatically assigned to network interfaces when no IP address is configured and are used for communication within a single subnet. | 169.254.1.2 |
| 172.16.0.0 – 172.31.255.255 | Private IPv4 | Used for local private networks within an organization that are not routable on the internet | 172.31.50.60 |
| 192.0.0.0 – 192.0.0.255 | IETF Protocol Assignments | Reserved for IETF protocol assignments | 192.0.0.1 |
| 192.0.2.0 – 192.0.2.255 | Documentation | Reserved for documentation and specification examples | 192.0.2.100 |
| 192.88.99.0 – 192.88.99.255 | IPv6 to IPv4 Relay | IPv6 to IPv4 relay anycast addresses used for 6to4 relay | 192.88.99.10 |
| 192.168.0.0 – 192.168.255.255 | Private IPv4 | Used for local private networks within an organization that are not routable on the internet | 192.168.254.1 |
| 198.18.0.0 – 198.19.255.255 | Benchmark Testing | Reserved for network benchmark tests | 198.18.10.20 |
| 198.51.100.0 – 198.51.100.255 | Documentation | Reserved for documentation and specification examples | 198.51.100.1 |
| 203.0.113.0 – 203.0.113.255 | Documentation | Reserved for documentation and specification examples | 203.0.113.100 |
| 224.0.0.0 – 239.255.255.255 | Multicast | Used to send messages to multiple recipients at the same time | 224.0.0.1 |
| 233.252.0.0 - 233.252.0.255 | Multicast | Used to send messages to multiple recipients at the same time | 233.252.0.1 |
| 240.0.0.0 – 255.255.255.254 | Reserved | Reserved for future use | 240.0.0.100 |
| 255.255.255.255 | Broadcast | Used to send messages to all hosts on the attached network | 255.255.255.255 |