Script.Util.HttpPost
Convenience function for simple HTTP POST requests — sends a body payload and returns the response body as a string.
Script.Util.HttpPost is a lightweight wrapper for HTTP POST requests. It sends a POST with the given body to the specified URL and returns the response body as a string. No Platform.Load is required.
For full control over headers, timeouts, HTTP method, and status code inspection, use Script.Util.HttpRequest instead.
Syntax
var body = Script.Util.HttpPost(url, contentType, payload);
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
url |
string | Yes | Target URL |
contentType |
string | Yes | MIME type of the request body (e.g. "application/json") |
payload |
string | Yes | Request body |
Return Value
Returns the response body as a string. Throws on connection failure. Does not expose the HTTP status code.
Examples
POST JSON data
var payload = Stringify({ event: "click", page: "/home" });
var body = Script.Util.HttpPost(
"https://api.example.com/events",
"application/json",
payload
);
var result = Platform.Function.ParseJSON(body + "");
POST form-encoded data
var payload = "email=jane%40example.com&first=Jane&last=Doe";
var body = Script.Util.HttpPost(
"https://forms.example.com/register",
"application/x-www-form-urlencoded",
payload
);
Notes
- Does not support custom request headers. Use
Script.Util.HttpRequestif you need to setAuthorizationor other headers. - Does not expose the HTTP status code. A non-2xx response returns the error body as a string with no way to detect the failure.
- Available in all SSJS execution contexts without
Platform.Load.