RequestParameter
Returns the value of a form post or query string parameter from the current request. Runtime-proven on a live Marketing Cloud Engagement CloudPage — names ignore case, values arrive decoded and unescaped, and a parameter supplied twice comes back comma-joined.
Syntax
RequestParameter(parameterName) → string
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
parameterName |
string | Yes | Parameter name, matched without regard to case |
Example
%%[
VAR @name
SET @name = RequestParameter("p")
]%%
Hello, %%=v(@name)=%%
Requested with ?p=hello, this renders Hello, hello.
A missing parameter is an empty string rather than a failure, so guard it where the page needs a value:
%%[
VAR @id
SET @id = RequestParameter("id")
IF Empty(@id) THEN
SET @id = "unknown"
ENDIF
]%%
The value arrives exactly as the caller sent it — escape it yourself before rendering it into markup, see below.
Return value
string — the decoded value of the named parameter, or an empty string when the request carries no such parameter.
The value domain is open, so there is no closed set of sentinel values to test for. The empty result is a real empty string: Length() on it answers 0 and Empty() answers true, in the same request that returns HTTP 200.
Behaviour
The name is matched without regard to case. A request carrying ?Foo=1 answers 1 for RequestParameter("foo"), RequestParameter("FOO") and RequestParameter("Foo") alike.
Percent-encoded characters arrive decoded. ?sp=a%20b gives a b at length 3, ?am=a%26b gives a&b at length 3, ?pc=100%25 gives 100%, and a plus sign in ?pl=a+b also gives a b.
A parameter supplied twice is joined, not resolved. ?x=1&x=2 returns the single string 1,2 at length 3 — neither 1 nor 2 wins. Code expecting a scalar silently receives a list.
An absent parameter is empty at HTTP 200. Nothing aborts, and Empty() on the same call answers true.
A platform-supplied name is readable, and is not protected. RequestParameter("PAGEURL") returned the full published page URL including its query string although the request set no such parameter — and ?PAGEURL=zzz then made the same call return zzz. Other platform names tried (PAGENAME, MID, JobID, subscriberkey) were empty on a CloudPage.
An empty name and a numeric name are accepted and always answer empty, without aborting. A number is not an alternative form of a parameter name, so the parameter type stays string.
The value is returned raw
Nothing is escaped on the way out: whatever characters the caller put in the query string come back verbatim, including &, % and angle brackets. Any value destined for markup, a URL or a script context must be escaped by the caller — this function performs no escaping of its own.
One request-level limit worth knowing while testing: a URL whose value contains a percent-encoded HTML tag, such as ?ht=%3Cb%3Ex%3C%2Fb%3E, is rejected with HTTP 422 before any AMPscript runs. The same URL fails even against a block that reads no such parameter, so it is a property of the request, not of this function.
Compared with QueryParameter and v
On a GET CloudPage, reading the same parameter with this function and with QueryParameter gives identical strings of identical length in every case above, and an in-page equality check answers the same. v is a different thing entirely — it outputs a value it is handed, it does not read the request.
Show test script
%%[
VAR @b, @rp, @qp, @word, @num
SET @b = RequestParameter("b")
SET @word = "zeta"
SET @num = 7
/* known-good control: renders on every request, so a run of HTTP 422s
can be told apart from a broken deploy */
OutputLine(Concat("CTRL=[", Uppercase("ok"), "]"))
OutputLine(Concat("GATE=[", @b, "]"))
/* a parameter this request set itself, read by both functions and
compared in-page */
IF @b == "basic" THEN
OutputLine(Concat("--- basic start ---"))
SET @rp = RequestParameter("p")
SET @qp = QueryParameter("p")
OutputLine(Concat("RP=[", @rp, "] LEN=[", Length(@rp), "]"))
OutputLine(Concat("QP=[", @qp, "] LEN=[", Length(@qp), "]"))
OutputLine(Concat("EQ=[", IIf(@rp == @qp, "same", "diff"), "]"))
OutputLine(Concat("--- basic done ---"))
ENDIF
/* percent-encoded and plus-encoded values arrive decoded; the length
proves a real single character rather than the escape sequence */
IF @b == "enc" THEN
OutputLine(Concat("--- enc start ---"))
OutputLine(Concat("SP=[", RequestParameter("sp"), "] LEN=[", Length(RequestParameter("sp")), "]"))
OutputLine(Concat("AM=[", RequestParameter("am"), "] LEN=[", Length(RequestParameter("am")), "]"))
OutputLine(Concat("PL=[", RequestParameter("pl"), "]"))
OutputLine(Concat("PC=[", RequestParameter("pc"), "]"))
OutputLine(Concat("SP_QP=[", QueryParameter("sp"), "]"))
OutputLine(Concat("AM_QP=[", QueryParameter("am"), "]"))
OutputLine(Concat("--- enc done ---"))
ENDIF
/* a parameter the request never carried: empty at HTTP 200 */
IF @b == "absent" THEN
OutputLine(Concat("--- absent start ---"))
SET @rp = RequestParameter("nosuchparam")
SET @qp = QueryParameter("nosuchparam")
OutputLine(Concat("ABS_RP=[", @rp, "] LEN=[", Length(@rp), "]"))
OutputLine(Concat("ABS_RP_CHK=[", IIf(Empty(@rp), "empty", "not-empty"), "]"))
OutputLine(Concat("ABS_QP_CHK=[", IIf(Empty(@qp), "empty", "not-empty"), "]"))
OutputLine(Concat("--- absent done ---"))
ENDIF
/* the name ignores case: fetch with a single mixed-case parameter */
IF @b == "case" THEN
OutputLine(Concat("--- case start ---"))
OutputLine(Concat("LOW=[", RequestParameter("foo"), "] UPP=[", RequestParameter("FOO"), "] MIX=[", RequestParameter("Foo"), "]"))
OutputLine(Concat("LOW_QP=[", QueryParameter("foo"), "] UPP_QP=[", QueryParameter("FOO"), "] MIX_QP=[", QueryParameter("Foo"), "]"))
OutputLine(Concat("--- case done ---"))
ENDIF
/* the same name twice: joined by a comma, proven by the length */
IF @b == "dup" THEN
OutputLine(Concat("--- dup start ---"))
OutputLine(Concat("DUP_RP=[", RequestParameter("x"), "] LEN=[", Length(RequestParameter("x")), "]"))
OutputLine(Concat("DUP_QP=[", QueryParameter("x"), "]"))
OutputLine(Concat("--- dup done ---"))
ENDIF
/* a name the platform supplies although the request never set it —
and, with ?b=plat&PAGEURL=zzz, a caller value overriding it */
IF @b == "plat" THEN
OutputLine(Concat("--- plat start ---"))
OutputLine(Concat("PAGEURL_RP=[", RequestParameter("PAGEURL"), "]"))
OutputLine(Concat("PAGEURL_QP=[", QueryParameter("PAGEURL"), "]"))
OutputLine(Concat("PAGENAME=[", RequestParameter("PAGENAME"), "]"))
OutputLine(Concat("MID=[", RequestParameter("MID"), "]"))
OutputLine(Concat("--- plat done ---"))
ENDIF
/* v() outputs a variable, a literal, a number and a nested call */
IF @b == "vread" THEN
OutputLine(Concat("--- vread start ---"))
SET @rp = RequestParameter("p")
OutputLine(Concat("V_VAR=[", v(@rp), "]"))
OutputLine(Concat("V_LIT=[", v("p"), "]"))
OutputLine(Concat("V_WORD=[", v(@word), "]"))
OutputLine(Concat("V_NUM=[", v(@num), "]"))
OutputLine(Concat("--- vread done ---"))
ENDIF
IF @b == "vnest" THEN
OutputLine(Concat("--- vnest start ---"))
OutputLine(Concat("V_NEST=[", v(RequestParameter("p")), "]"))
OutputLine(Concat("--- vnest done ---"))
ENDIF
IF @b == "vnumlit" THEN
OutputLine(Concat("--- vnumlit start ---"))
OutputLine(Concat("V_NUMLIT=[", v(5), "]"))
OutputLine(Concat("--- vnumlit done ---"))
ENDIF
/* an empty name and a numeric name: accepted, always empty */
IF @b == "rpempty" THEN
OutputLine(Concat("--- rpempty start ---"))
OutputLine(Concat("RPEMPTY=[", RequestParameter(""), "] QPEMPTY=[", QueryParameter(""), "]"))
OutputLine(Concat("--- rpempty done ---"))
ENDIF
IF @b == "rpnum" THEN
OutputLine(Concat("--- rpnum start ---"))
OutputLine(Concat("RPNUM=[", RequestParameter(1), "] QPNUM=[", QueryParameter(1), "]"))
OutputLine(Concat("--- rpnum done ---"))
ENDIF
/* argument counts the signatures do not allow: each aborts its own
branch with HTTP 422 while every branch above still renders */
IF @b == "rp0" THEN
OutputLine(Concat("RP0=[", RequestParameter(), "]"))
ENDIF
IF @b == "rp2" THEN
OutputLine(Concat("RP2=[", RequestParameter("p", 1), "]"))
ENDIF
IF @b == "qp0" THEN
OutputLine(Concat("QP0=[", QueryParameter(), "]"))
ENDIF
IF @b == "qp2num" THEN
OutputLine(Concat("QP2NUM=[", QueryParameter("p", 1), "]"))
ENDIF
IF @b == "qp2zero" THEN
OutputLine(Concat("QP2ZERO=[", QueryParameter("p", 0), "]"))
ENDIF
IF @b == "qp2bool" THEN
OutputLine(Concat("QP2BOOL=[", QueryParameter("p", true), "]"))
ENDIF
IF @b == "v0" THEN
OutputLine(Concat("V0=[", v(), "]"))
ENDIF
IF @b == "v2" THEN
OutputLine(Concat("V2=[", v(@word, @word), "]"))
ENDIF
]%%
Every marker and label in the test script goes through Concat(...), including single-argument ones. A bare string literal passed to OutputLine renders an empty line while the page still returns HTTP 200, so the marker silently vanishes.
The bundled harness is shared by all three functions and is driven entirely by the query string, so one deploy covers every case — a POST body is not exercised, so the form-post path the official reference describes is untested here.
Availability
| Platform | Available |
|---|---|
| Marketing Cloud Engagement | Yes |
| Marketing Cloud Next | No |
See also
- QueryParameter — the same function on a GET
- v — outputs a value inline
- Differs from docs: case, duplicates and raw values
- Official reference · ampscript.guide