HTTPGet
→ stringSends an HTTP GET request to the specified URL and returns the response body as a string.
Available in:
Email
CloudPage
Automation
Triggered Send
Syntax
Platform.Function.HTTPGet(url [, encoding [, followRedirects [, headerNames, headerValues]]])
1–5 arguments
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
url |
string | Yes | Target URL |
encoding |
string | No | Response encoding (default: "UTF-8") |
followRedirects |
boolean | No | Follow HTTP redirects (default: true) |
headerNames |
string[] | No | Array of header names to send |
headerValues |
string[] | No | Array of header values (parallel to headerNames) |
Examples
// Simple GET
var response = Platform.Function.HTTPGet("https://api.example.com/data");
var data = Platform.Function.ParseJSON(response + "");
// GET with custom headers
var headers = ["Authorization", "Content-Type"];
var values = ["Bearer mytoken", "application/json"];
var response2 = Platform.Function.HTTPGet(
"https://api.example.com/secure",
"UTF-8",
true,
headers,
values
);
For more control over request options, use Script.Util.HttpRequest or HTTP.Get()/HTTP.GetRequest() from the Core library.
Return Value
Returns the response body as a string. Throws on connection failure. Does not expose status code — use HTTP.GetRequest() for status codes.