HTTP.Post sends a POST with the given content type and body. It returns an object that includes status information and the response body (see Core HTTP documentation for the exact shape).

Syntax

var response = HTTP.Post(url, contentType, payload[, headerNames, headerValues]);

Parameters

Name Type Required Description
url string Yes Target URL
contentType string Yes MIME type of the request body
payload string Yes Request body string
headerNames string[] No Additional header names
headerValues string[] No Values paired with headerNames

Return value

Returns an object (not a bare string). Parse Content or equivalent field after coercing with String(...).

Example

Platform.Load("core", "1.1.5");

var payload = Stringify({
    event: "form_submit",
    email: submitterEmail,
    timestamp: Platform.Function.Now()
});

var response = HTTP.Post(
    "https://api.example.com/events",
    "application/json",
    payload,
    ["X-API-Key"],
    ["mysecretkey"]
);

var result = Platform.Function.ParseJSON(String(response.Content));

See Also