Script.Util.HttpGet()
Retrieves information from a URL by issuing an HTTP GET request. Unlike the Platform and Core GET functions, this request handler caches content for use in mail sends, which can improve the performance of email sends.
When you use the handler’s send()
method, it returns a Script.Util.HttpResponse object that contains the response data.
This request handler only works with HTTP on port 80 and HTTPS on port 443.
The Script.Util.HttpGet
request handler has the properties listed in this table.
Ordinal | Type | Description |
---|---|---|
1 | String | Required. The URL to retrieve content from. |
The Script.Util.HttpGet
request handler has the methods listed in this table.
Method | Description |
---|---|
clearHeaders() | Removes all custom headers set for the request. |
removeHeader(String) | Indicates a specific header to remove from the request. |
send() | Sends the request and returns a response data object. The send() method times out after 30 seconds. |
setHeader(String, String) | Sets the headers to include in the GET request. If you use this property to specify a header, content caching is disabled. |
The Script.Util.HttpGet
request handler has the configuration properties listed in this table.
Property | Type | Description |
---|---|---|
continueOnError | Boolean | Specifies how to handle errors. If the value is true , the request continues after receiving an error. If the value is false , the request produces an exception. The default value is false . |
emptyContentHandling | Number | Indicates what to do if the GET request doesn’t return any content. Possible values:
|
retries | Number | The number of times to retry the GET request if a failure occurs. After the final retry, the request produces an exception. The default value is 1 . |
To use this request handler, initialize it and provide the destination URL. This code example also shows how to specify some request headers and configure the parameters of the request.
The example outputs the full body of the response received from the server.