Platform.Request provides methods to inspect every aspect of the incoming HTTP request in CloudPage, JSON Resource, and Triggered Send contexts.

Does not require Platform.Load.

Platform.Request and the Core Library Request object are two different objects — not aliases. They share a name and purpose but differ in member set and access style. Platform.Request (this page) works without Platform.Load and exposes a rich mix of properties (RequestURL, Method, ClientIP, QueryString, …) and getter methods (GetQueryStringParameter(), GetCookieValue(), GetRequestHeader(), …). Core Request is a smaller, method-only set — six zero-arg context methods (Request.URL(), Request.Method(), Request.PagePath(), …) plus the single-argument value getters Request.GetQueryStringParameter(name) and Request.GetFormField(name) — that requires Platform.Load("core", ...). For example, the current URL is the RequestURL property here, but the URL() method on Core Request. Pick the object that has the member you need — don’t assume they mirror each other.

Properties

Property Type Description
Platform.Request.Browser object Browser metadata: Platform, Browser, Version, MajorVersion, MinorVersion
Platform.Request.ClientIP string IP address of the requesting client
Platform.Request.HasSSL boolean Whether the current request supports SSL (HTTPS)
Platform.Request.IsSSL boolean Whether the current request used an SSL (HTTPS) connection
Platform.Request.Method string HTTP method: "GET" or "POST"
Platform.Request.QueryString string Full raw query string of the request URL
Platform.Request.ReferrerURL string URL of the referring web address
Platform.Request.RequestURL string Full resolved URL of the current page
Platform.Request.UserAgent string User-agent string of the requesting browser

On a CloudPage GET, these are CLR-backed request values rather than ordinary JavaScript primitives. Convert string properties with String(...) before strict comparison; test HasSSL and IsSSL directly in conditions. UserAgent and ReferrerURL throw when their corresponding headers are absent, so prefer GetRequestHeader(...) when the header is optional.

Show test script
<script runat="server">
/*
 * Chapter: Properties
 * Proves:
 *   1. Request properties are available without Platform.Load on CloudPage GET.
 *   2. Method, query string, URL, referrer, IP, and SSL values have their CLR-backed shapes.
 *   3. QueryString includes the leading question mark and RequestURL includes it.
 *   4. Browser exposes its five named fields even when the user agent is unrecognized.
 * EXPECTED OUTPUT: every assertion line starts with PASS.
 */
function assert(id, actual, expected) {
    Platform.Response.Write((actual === expected ? "PASS " : "FAIL ") + id + " -> [" + actual + "]\n");
}
function capture(fn) {
    try { return { threw: false, value: fn() }; } catch (ex) { return { threw: true, message: String(ex.message) }; }
}
assert("Platform.Request is available without Platform.Load", typeof Platform.Request, "clr");
assert("Method is CLR-backed", typeof Platform.Request.Method, "clr");
assert("Method converts to GET", String(Platform.Request.Method), "GET");
assert("QueryString is CLR-backed", typeof Platform.Request.QueryString, "clr");
assert("QueryString includes leading question mark", String(Platform.Request.QueryString).charAt(0), "?");
assert("RequestURL is CLR-backed", typeof Platform.Request.RequestURL, "clr");
assert("RequestURL contains the controlled query", String(Platform.Request.RequestURL).indexOf("present=value") >= 0 ? "yes" : "no", "yes");
assert("ReferrerURL reads the controlled Referer header", String(Platform.Request.ReferrerURL), "https://example.test/referrer");
assert("ClientIP is a populated CLR string", typeof Platform.Request.ClientIP, "clr");
assert("ClientIP is non-empty", String(Platform.Request.ClientIP).length > 0 ? "yes" : "no", "yes");
assert("HasSSL is a CLR boolean", typeof Platform.Request.HasSSL, "clr");
assert("IsSSL is a CLR boolean", typeof Platform.Request.IsSSL, "clr");
assert("HTTPS request makes HasSSL truthy", Platform.Request.HasSSL ? "true" : "false", "true");
assert("HTTPS request makes IsSSL truthy", Platform.Request.IsSSL ? "true" : "false", "true");
assert("HasSSL and IsSSL render identically", String(Platform.Request.HasSSL), String(Platform.Request.IsSSL));
var browser = Platform.Request.Browser;
assert("Browser is CLR-backed", typeof browser, "clr");
assert("Browser.Platform is readable", typeof browser.Platform, "clr");
assert("Browser.Browser is readable", typeof browser.Browser, "clr");
assert("Browser.Version is readable", typeof browser.Version, "clr");
assert("Browser.MajorVersion is readable", typeof browser.MajorVersion, "clr");
assert("Browser.MinorVersion is readable", typeof browser.MinorVersion, "clr");
var agent = capture(function () { return Platform.Request.UserAgent; });
assert("UserAgent is readable when the controlled request sends it", agent.threw ? "threw" : "returned", "returned");
assert("UserAgent is CLR-backed", agent.threw ? "threw" : typeof agent.value, "clr");
</script>

Methods

Method Returns Description
GetCookieValue(name) string Read a cookie value
GetFormField(name) string Read a named POST form field, or null when absent (does not read GET query parameters)
GetPostData([encoding]) string Read raw POST body (optional character encoding)
GetQueryStringParameter(name) string Read a URL query parameter
GetRequestHeader(name) string Read a request header
GetUserLanguages() ⚠️ string Read the browser Accept-Language header value — GetUserLanguages() as called is not defined at runtime (the engine does not resolve it; throws at every arity tried); use GetRequestHeader("Accept-Language")
Show test script
<script runat="server">
/*
 * Chapter: Methods
 * Proves:
 *   1. Query getters distinguish absent null from empty string, join repeats with a comma,
 *      match names case-insensitively, decode URL encoding, and coerce numeric names.
 *   2. GetFormField does not read GET query parameters; absent form/cookie/header values are strict null.
 *   3. Cookie and request-header getters read controlled values; header names are case-insensitive.
 *   4. GetPostData returns an empty string on a GET, including its second read.
 *   5. GetUserLanguages is not callable; GetRequestHeader is the working replacement.
 *   6. Platform.Request needs no Core load, while the distinct bare Request object appears after Core loads.
 * EXPECTED OUTPUT: every assertion line starts with PASS.
 */
function assert(id, actual, expected) {
    Platform.Response.Write((actual === expected ? "PASS " : "FAIL ") + id + " -> [" + actual + "]\n");
}
function assertThrows(id, fn) {
    try { fn(); Platform.Response.Write("FAIL " + id + " -> [did not throw]\n"); }
    catch (ex) { Platform.Response.Write("PASS " + id + " -> [" + String(ex.message) + "]\n"); }
}
function typeOf(fn) {
    try { return fn(); } catch (ex) { return "threw:" + String(ex.message); }
}
var absent = Platform.Request.GetQueryStringParameter("absent");
assert("present query parameter returns its value", Platform.Request.GetQueryStringParameter("present"), "value");
assert("DEV absent query parameter is strict null (official docs: empty string)", absent === null ? "null" : "other", "null");
assert("absent query parameter is falsy", absent ? "true" : "false", "false");
assert("absent query parameter safely equals null", absent == null ? "true" : "false", "true");
assert("empty query parameter returns empty string", Platform.Request.GetQueryStringParameter("empty"), "");
assert("repeated query parameter returns comma-joined values", Platform.Request.GetQueryStringParameter("repeat"), "1,2");
assert("query parameter names are case-insensitive", Platform.Request.GetQueryStringParameter("casename"), "Upper");
assert("percent-encoded space is decoded", Platform.Request.GetQueryStringParameter("space"), "hello world");
assert("plus sign is decoded as space", Platform.Request.GetQueryStringParameter("plus"), "hello world");
assert("percent escapes are decoded once", Platform.Request.GetQueryStringParameter("percent"), "%25");
var unicode = Platform.Request.GetQueryStringParameter("unicode");
assert("UTF-8 query value first code point", unicode.charCodeAt(0), 228);
assert("UTF-8 query value second code point", unicode.charCodeAt(1), 246);
assert("UTF-8 query value third code point", unicode.charCodeAt(2), 252);
assert("null parameter name returns strict null", Platform.Request.GetQueryStringParameter(null) === null ? "null" : "other", "null");
var unset;
assert("undefined parameter name returns strict null", Platform.Request.GetQueryStringParameter(unset) === null ? "null" : "other", "null");
assert("numeric parameter name is coerced", Platform.Request.GetQueryStringParameter(42), "numeric");
assert("GetFormField does not read GET query values", Platform.Request.GetFormField("present") === null ? "null" : "other", "null");
assert("absent form field is strict null", Platform.Request.GetFormField("absent") === null ? "null" : "other", "null");
assert("cookie getter reads controlled cookie", Platform.Request.GetCookieValue("probeCookie"), "cookie-value");
assert("DEV absent cookie is strict null (official docs: empty string)", Platform.Request.GetCookieValue("absentCookie") === null ? "null" : "other", "null");
assert("header getter reads controlled header", Platform.Request.GetRequestHeader("X-Request-Probe"), "controlled-header");
assert("header names are case-insensitive", Platform.Request.GetRequestHeader("x-request-probe"), "controlled-header");
assert("Accept-Language header is readable", Platform.Request.GetRequestHeader("Accept-Language"), "de-DE,en;q=0.7");
assert("absent header is strict null", Platform.Request.GetRequestHeader("X-Absent-Probe") === null ? "null" : "other", "null");
assertThrows("DEV GetUserLanguages throws (official docs: returns Accept-Language)", function () { Platform.Request.GetUserLanguages(); });
assert("workaround reads Accept-Language directly", Platform.Request.GetRequestHeader("Accept-Language"), "de-DE,en;q=0.7");
var firstBody = Platform.Request.GetPostData();
var secondBody = Platform.Request.GetPostData();
assert("GET first GetPostData call is empty string", firstBody, "");
assert("GET second GetPostData call is empty string", secondBody, "");
assert("bare Request is undefined before Platform.Load", typeOf(function () { return typeof Request; }), "undefined");
Platform.Load("core", "1.1.5");
assert("bare Request appears after Platform.Load", typeOf(function () { return typeof Request; }), "object");
assert("bare Request is distinct but reads the same query value", Request.GetQueryStringParameter("present"), "value");
</script>


Platform.Request.GetQueryStringParameter

Platform.Request.GetQueryStringParameter(parameterName)

Returns the value of a URL query string parameter. Returns null if the parameter is not present (runtime-verified — the official docs’ claim of an empty string is incorrect). An explicitly empty value returns ""; repeated values are returned as one comma-joined string in URL order. Parameter names are case-insensitive, + and percent-encoded spaces decode to spaces, percent escapes decode once, and UTF-8 escapes decode to Unicode characters.

Parameters

Name Type Required Description
parameterName string Yes Query parameter name

Examples

// URL: /page?id=42&mode=preview
var id = Platform.Request.GetQueryStringParameter("id");     // "42"
var mode = Platform.Request.GetQueryStringParameter("mode"); // "preview"
var missing = Platform.Request.GetQueryStringParameter("foo"); // null

Platform.Request.GetFormField

Platform.Request.GetFormField(fieldName)

Reads a submitted form field from a POST form body (application/x-www-form-urlencoded or multipart/form-data). On a plain CloudPage GET it does not fall back to query parameters; it returns null even when the same name is present in the URL.

Examples

var email = Platform.Request.GetFormField("email");
var firstName = Platform.Request.GetFormField("firstName");

Platform.Request.GetPostData

Platform.Request.GetPostData([encoding])

Returns the raw POST body as a string. Typically used for JSON or XML payloads sent with content-type application/json. On a GET request, both the first and subsequent reads return an empty string.

When encoding is omitted, the platform default applies (often a legacy Windows code page). Pass an encoding name such as "UTF-8" when the client sends UTF-8.

Examples

// CORRECT — read once, reuse the variable
var rawBody = Platform.Request.GetPostData();
var payload = Platform.Function.ParseJSON(rawBody + "");

// WRONG — second call returns ""
var a = Platform.Request.GetPostData();
var b = Platform.Request.GetPostData(); // b === ""

Checking Request Method First

if (String(Platform.Request.Method) === "POST") {
    var rawBody = Platform.Request.GetPostData();
    if (rawBody) {
        var data = Platform.Function.ParseJSON(rawBody + "");
        // process data
    }
}

Platform.Request.GetUserLanguages

Platform.Request.GetUserLanguages()

Is documented to return the raw value of the HTTP Accept-Language header (for example a comma-separated list with quality values).

Workaround

// GetUserLanguages() is not defined at runtime — read the header directly.
var langs = Platform.Request.GetRequestHeader("Accept-Language");
if (langs) {
    Write("<!-- Accept-Language: " + langs + " -->");
}

Platform.Request.GetRequestHeader

Platform.Request.GetRequestHeader(headerName)

Returns the value of an HTTP request header. Header names are case-insensitive. Returns null when the header is absent.

Examples

var contentType = Platform.Request.GetRequestHeader("Content-Type");
var authHeader = Platform.Request.GetRequestHeader("Authorization");
var customToken = Platform.Request.GetRequestHeader("X-API-Token");

// Token authentication pattern
var token = Platform.Request.GetRequestHeader("X-Auth-Token");
var expectedToken = Platform.Function.Lookup("Config", "value", "key", "apiToken");
if (token !== expectedToken) {
    Write(Stringify({ status: 401, statusMessage: "Unauthorized", error: "Unauthorized" }));
    return;
}

Platform.Request.GetCookieValue

Platform.Request.GetCookieValue(cookieName)

Returns the value of a cookie sent with the request. Returns null when the cookie is absent.

Examples

var sessionId = Platform.Request.GetCookieValue("sfmc_session");
if (!sessionId) {
    // No session — redirect to login
    Platform.Response.Redirect("/login", false);
}

Platform.Request.RequestURL

Platform.Request.RequestURL

Returns the absolute URL of the current CloudPage, including the query string. The value is a CLR string, so convert it with String(...) before strict comparison.

Examples

var currentUrl = Platform.Request.RequestURL;

Platform.Request.Browser

Platform.Request.Browser

Returns an object describing the requesting client’s browser with the following fields: Platform, Browser, Version, MajorVersion, MinorVersion.

Examples

var browser = Platform.Request.Browser;
Write(Stringify(browser));
// { "Platform": "WinNT", "Browser": "Chrome", "Version": "124.0", "MajorVersion": 124, "MinorVersion": 0 }

Platform.Request.ClientIP

Platform.Request.ClientIP

Returns the IP address of the requesting client as a string.

Examples

var ip = Platform.Request.ClientIP;
Write("Request from: " + ip);

Platform.Request.HasSSL

Platform.Request.HasSSL

Returns a CLR boolean that is truthy when the request uses HTTPS. Test it directly in a condition; strict comparison with JavaScript true does not match.

Examples

if (!Platform.Request.HasSSL) {
    Platform.Response.Redirect("https://" + Platform.Request.RequestURL, false);
}

Platform.Request.IsSSL

Platform.Request.IsSSL

Returns the same CLR boolean value as HasSSL. Test it directly in a condition rather than with strict equality.


Platform.Request.Method

Platform.Request.Method

Returns the HTTP method of the current request as a CLR string. Coerce it before strict comparison — the raw value does not match a literal, but both String(Platform.Request.Method) === "GET" and ("" + Platform.Request.Method) === "GET" are true (runtime-verified).

Examples

var method = String(Platform.Request.Method);
if (method === "POST") {
    var body = Platform.Request.GetPostData();
    // handle POST
}

Platform.Request.QueryString

Platform.Request.QueryString

Returns the full raw query string of the request URL including the leading ?. The CLR string preserves the encoded form; use GetQueryStringParameter(name) for decoded values.

Examples

var qs = Platform.Request.QueryString;
// e.g. "id=42&mode=preview"

Platform.Request.ReferrerURL

Platform.Request.ReferrerURL

Returns the HTTP Referer header as a CLR string. If that header is absent, reading this property throws a null-reference error; use GetRequestHeader("Referer") when the referrer is optional.

Examples

var referrer = Platform.Request.ReferrerURL;
if (referrer) {
    Write("<!-- Referred from: " + referrer + " -->");
}

Platform.Request.UserAgent

Platform.Request.UserAgent

Returns the User-Agent header as a CLR string. If the header is absent, reading this property throws a null-reference error; use GetRequestHeader("User-Agent") for an optional read. Use the populated value with Platform.Function.IsCHTMLBrowser() to detect browser types.

Examples

var ua = Platform.Request.UserAgent;
var isCHTML = Platform.Function.IsCHTMLBrowser(ua);

Complete Request Handler Pattern

var method = String(Platform.Request.Method);

if (method === "GET") {
    var id = Platform.Request.GetQueryStringParameter("id");
    if (!id) {
        Write(Stringify({ status: 400, statusMessage: "Bad Request", error: "id is required" }));
    } else {
        var record = Platform.Function.Lookup("Records", "data", "id", id);
        Platform.Response.ContentType = "application/json";
        Write(Stringify({ id: id, data: record }));
    }
} else if (method === "POST") {
    var rawBody = Platform.Request.GetPostData();
    try {
        var body = Platform.Function.ParseJSON(rawBody + "");
        // process body...
        Platform.Response.ContentType = "application/json";
        Write(Stringify({ status: "ok" }));
    } catch(e) {
        Write(Stringify({ status: 400, statusMessage: "Bad Request", error: "Invalid JSON" }));
    }
}
Show test script
<script runat="server">
/*
 * Chapter: Complete Request Handler Pattern
 * Proves:
 *   1. CLR-backed Method must be converted before strict string comparison.
 *   2. Truthiness is a safe guard for a missing query parameter.
 *   3. The controlled GET enters the GET branch and reads its present parameter.
 * EXPECTED OUTPUT: every assertion line starts with PASS.
 */
function assert(id, actual, expected) {
    Platform.Response.Write((actual === expected ? "PASS " : "FAIL ") + id + " -> [" + actual + "]\n");
}
var rawMethod = Platform.Request.Method;
var method = String(rawMethod);
assert("DEV raw CLR Method is not strictly equal to GET (official docs imply string)", rawMethod === "GET" ? "equal" : "not-equal", "not-equal");
assert("converted Method is strictly equal to GET", method === "GET" ? "equal" : "not-equal", "equal");
assert("controlled request enters GET branch", method, "GET");
assert("present id-style parameter can be read", Platform.Request.GetQueryStringParameter("present"), "value");
assert("missing parameter is safely rejected by truthiness", Platform.Request.GetQueryStringParameter("absent") ? "present" : "missing", "missing");
</script>

See Also