Skip to main content
Version: 4.46.0

HTTP request (deprecated)

The HTTP request component allows you to execute HTTP requests.

It supports the following methods: GET, POST, PUT, DELETE, PATCH and has built-in support for basic authentication and bearer token authentication.

You can control the URL, headers and body using Handlebars templates in the configuration or sending the values as parameters to the input.

Handlebars

This component lets you use Handlebars templates. More information about Handlebars can be found in this section

Configuration

General

Request method

The request method used when sending the request. (default: GET) This can be overwritten by sending the method as part of the input message.

URL

The URL to send the request to. This can be overwritten by sending the url as part of the input message.

Configure header

Enables you to configure headers. This can be overwritten by sending the headers as part of the input message.

Headers is a JSON object with the header name as the key and the header value as the value.

Configure body

Enables you to configure the body. This can be overwritten by sending the body as part of the input message.

Body as

The type of the body. (default: json). This can be overwritten by sending the bodyAs as part of the input message.

When using the binary option, the localReference is required in the body.

When using the form-data option, at least one of the multipartText or multipartBinary is required in the body.

For both scenarios, there is an example at the end of this section.

Hooks

A hook lets you execute plain JavaScript code within a sandbox making it secure and safe.

It has the same functions as the code component with the following additions:

  • recall(requestOptions, withMessageHook, priority); use to internally recall the HTTP request component.

  • recallWithConfig(requestOptions, withMessageHook, priority); use to internally recall the HTTP request component using the configuration headers and body.

  • execute(requestOptions).finally(() => done()); use to execute a request immediately. Note that the done function needs to be called manually since the execute function is asynchronous. Scroll down to the Calling done section for more information.

Parameters:

  • requestOptions object describing the request. It has the same options as the input message.

  • withMessageHook boolean indicating if the message hook should be triggered. (default: false)

  • priority integer indicating the priority of the request. A lower value is indicating a higher priority. Requests with a higher priority are put in front of the rate limiter queue (default: 5)

Note that the recall and recallWithConfig functions schedule a consecutive call using the rate limiter queue. To execute a request immediately, use the execute function.

If authentication is enabled, authentication headers are added to the request automatically.

Enable message hook

Enables you to configure a message hook that triggers when a message is received.

Message hook

This hook gets triggered by an incoming message. It has access to the value object and allows you internally recall the component by using the recall function. This allows for example to get a ticket from a service and then use the ticket to get the data.

Enable response hook

Enables you to configure a response hook. It gets triggered when the response is received.

Response hook

This hook has access to the response object and allows you internally recall the component by using the recall function. This allows consecutively executing requests like fetching the children of a parent and then fetching the metadata of the children. Here you can find an example of a response hook that is used for extracting Sharepoint Online using the Graph-API.

Use response to access the response object.

Note that both recall and recallWithConfig share the same hook and it will trigger if responseHookEnabled is set to true. Therefore it is important to do some validation in the hook to prevent infinite loops. In the Sharepoint Online example, this is done by adding the action to the recall value and checking it before doing any consecutive calls. You could also explicitly set responseHookEnabled to false in requestOptions.

Calling done

Because JavaScript allows you to write code asynchronously, you need to call the done function when your code is done. When you are not using any asynchronous syntax, the done call should be at the end of your script.

    // your code
done();

Note: in cases where you are calling return in the global scope, you need to call done before the return statement.

Authentication

Type

The type of authentication used. (default: none)

SSL/TLS

Client Certificate File

If TLS is enabled, a Client Certificate File is required. This field should contain the path to the certificate. In order to access the local filesystem, the XILL4_WORKDIRS environment variable must be set to the path of the directory to be accessed.

Example: .\client-cert.pem

Client Key File

If TLS is enabled, a Client Key File is required. This field should contain the path to the key.

Example: .\client-key.pem

Certificate Authority File

If TLS is enabled, a Certificate Authority File can be supplied. It is most likely required when using Self-Signed Certificates. This field should contain the path to the Root Certificate Authority file.

Example: .\ca.pem

Reject Unauthorized Request

When using Self-Signed Certificates and no Root CA is available, this option needs to be disabled before they can be used. This option is by default set to true.

Rate limit

Request limit

The max amount of requests during the interval.

Interval

The interval in milliseconds in which the requests happen. Should be a multiple of 250.

Max concurrent

The maximum concurrent executions.

Response

Resolve body only

If enabled it will only resolve the body of the response.

Type

The type of response. (default: json)

isStream

Specifies if the response should be stored in the Content Store.

Timeout

Response timeout

The response timeout in milliseconds. The time in which the headers need to be received.

Request timeout

The request timeout in milliseconds. The total time for the request.

Redirects

Follow redirects

If enabled it will follow redirects.

Maximum number of redirects to follow

The maximum number of redirects to follow.

Database

Connection string

A MongoDB connection string.

Example: mongodb://<username>:<password>@localhost:27017/<databaseName>

Here <databaseName> is the database to use.

Use TLS

Whether or not to use TLS in case your mongoDB requires TLS.

*Allow Invalid Certificates

Checking this will disable certificate validation. Warning: specifying this option in a production environment makes your application insecure and potentially vulnerable to expired certificates and to foreign processes posing as valid client instances.

Certificate Authority File

One or more certificate authorities to trust when making a TLS connection. In order to access the local filesystem, the XILL4_WORKDIRS environment variable must be set to the path of the directory to be accessed.

Example: .\ca.pem

Inputs

Input

Can be any message for triggering the request or a message with the following properties:

method - The request method.

url - The URL to send the request to.

headers - The headers to send.

body - The body to send.

bodyAs - The type of body to send, valid options are json, x-www-form-urlencoded, text, form-data and binary.

hookEnabled - If enabled it will execute the response hook.

responseType - The type of response, valid options are json, text, buffer.

isStream - Specifies if the response should be stored in the Content Store.

If the properties are not set, the values from the configuration will be used.

Outputs

Output

The response of the request.

Downloading files

To download a file, set isStream to true.

Uploading files

To upload a file, you can set bodyAs to binary or form-data. When using form-data, you can also add other form fields.

Example body when uploading a file using binary and the file source is a file path:

{
"externalReference" : "C:\\Users\\xill\\Desktop\\test.txt",
}

Example body when uploading a file using binary and the file source is the Content Store:

{
"localReference" : "f02a73168ae19095d70f8f0ebc84cd135add4ccf8e008a9723a53c4865609f13ceed0079b8f56f92f1906843c8891e3165d198645c3bd33df5a224665a1060d1",
}

Example body when uploading a file using form-data and the file source is a file path:

{
"multipartText" : {
"field1" : "value1",
"field2" : "value2"
},
"multipartBinary":{
"field3" : "C:\\Users\\xill\\Desktop\\test.txt",
}
}

Example body when uploading a file using form-data and the file source is the Content Store.

{
"multipartText" : {
"field1" : "value1",
"field2" : "value2"
},
"multipartBinary":{
"field3" : {
"localReference" : "f02a73168ae19095d70f8f0ebc84cd135add4ccf8e008a9723a53c4865609f13ceed0079b8f56f92f1906843c8891e3165d198645c3bd33df5a224665a1060d1",
"fileName" : "test.txt"
}
}
}

Notice how field3 now is an object with a localReference property and a mandatory fileName property. This is because the filename can't be derived from the binary.

Multi-part form data

When using form-data as the bodyAs value, at least one of multipartTextor multipartBinary is required. This property should be an object with the field names as keys and the field values as values.