Script.Util.HttpRequest

Issues an HTTP request to a specified URL. This function doesn’t perform caching for email content. The default timeout value for this function is 30 seconds.

Script.Util.HttpRequest(1)

OrdinalTypeDescription
1stringRequired. The URL to issue the HTTP request to.

You can call several methods to modify the configuration of the HTTP request.

send()

Sends the request to the destination endpoint.

removeHeader()

Excludes a header from the request.

clearHeader()

Removes all custom headers from the request.

setHeader()

Adds a header to the request. Specify each header as a name-value pair.

You can’t use the setHeader() method to change the host and content-length headers. The value of host is always set to the domain of the URL that the request was sent to. The value of content-length is always set to the length of the content in the request.

You can also set several properties to tailor the request to your needs.

contentType

(String) The content type to use in POST requests, such as application/json or application/x-www-form-urlencoded.

encoding

(String) The content encoding to use in POST requests, such as UTF-8.

method

(String) The HTTP verb to use in the request. Accepted values: GET, DELETE, HEAD, OPTIONS, PATCH, POST, PUT.

postData

(String) The request body. This value is required for POST requests.

This example issues a POST request to a destination server.

The example outputs the full body of the response received from the server.