Platform.Function.HTTPGet is an AMPscript-compatible function available in SSJS. It sends an HTTP GET request and returns the response body as a string. Unlike the Core library’s HTTP.Get, it does not require Platform.Load.

Syntax

var body = Platform.Function.HTTPGet(url [, encoding [, followRedirects [, headerNames, headerValues]]]);

Parameters

Name Type Required Description
url string Yes Target URL
encoding string No Response character encoding (default: "UTF-8")
followRedirects boolean No Follow HTTP redirects (default: true)
headerNames string[] No Array of request header names
headerValues string[] No Array of corresponding header values

Return Value

Returns the response body as a string. Throws on connection failure. Does not expose the HTTP status code — use HTTP.GetRequest or Script.Util.HttpRequest if you need status code inspection.

Examples

Simple GET

var body = Platform.Function.HTTPGet("https://api.example.com/data");
var data = Platform.Function.ParseJSON(body + "");

GET with authorization header

var headerNames = ["Authorization"];
var headerValues = ["Bearer " + accessToken];
var body = Platform.Function.HTTPGet(
    "https://api.example.com/secure",
    "UTF-8",
    true,
    headerNames,
    headerValues
);
var result = Platform.Function.ParseJSON(body + "");

Notes

Platform.Function.HTTPGet does not expose the HTTP status code. Use Script.Util.HttpRequest or HTTP.GetRequest when you need to inspect the response code.

Available in all SSJS execution contexts — no Platform.Load required.

See Also