Syntax

Platform.Function.HTTPGet(url, continueOnError[, emptyContentHandling, headerNames, headerValues, statusVariable])
2–6 arguments

Parameters

Name Type Required Description
url string Yes URL to request
continueOnError boolean Yes When true, the request terminates if an error occurs. When false, the request continues on error.
emptyContentHandling number No How to handle a URL that returns empty content: 0 = allow empty, 1 = return error, 2 = skip subscriber
headerNames string[] No Array of header names to include in the GET request
headerValues string[] No Array of header values corresponding to headerNames
statusVariable number[] No Array that receives the HTTP status code: 0 = success, -1 = URL not found, -2 = HTTP error, -3 = success but no content

Examples

// Simple GET with error handling
var status = [0];
var content = Platform.Function.HTTPGet(
    "https://api.example.com/data",
    false,
    0,
    null,
    null,
    status
);
if (status[0] === 0) {
    var obj = Platform.Function.ParseJSON(content);
}

// GET with custom headers
var status2 = [0];
var content2 = Platform.Function.HTTPGet(
    "https://api.example.com/secure",
    false,
    0,
    ["x-request-id"],
    ["sampleValue"],
    status2
);

For full transport control, use HTTP.Get (Core) or Script.Util.HttpRequest.

Return Value

Returns the response body as a string. The HTTP status code is written into the statusVariable array argument (if provided) as statusVariable[0].

See Also