4

I'm retrieving a URL parameter from a CloudPage. What is the difference between RequestParameter() and QueryParameter()? They appear to do the same thing. Are there scenarios where you would need to use one over the other?

1 Answer 1

7

The "query" of a page's life cycle is the stuff after the "?" character in a URL, while a request parameter is one placed in the body of the request (a "form post"). Let's look at an example of what a browser might send to a server:

POST /path/to/file?The-Query-String=Here&Query-Values=Are-In-The-Url HTTP/1.1
Host: myhost.com
Content-Length: 52
Content-Type: x-www-form-urlencoded

Request-Body=Here&Request-Values=Are-In-The-Form-Post

However, in the documentation for the RequestParameter, it explicitly states that it can return query parameters (the part in the URL), and values in the form's post.

You can use QueryParameter to ignore form values, while you'd want to use RequestParameter if you need to read the values from a form post. RequestParameter may return more values than QueryParameter, especially if the request is a form post.

2
  • I built a simple HTML submit form post, and both functions (QueryParameter and RequestParameter) can capture element id values. Is it another form post you was mentioning?
    – Duc Le
    Jun 14 at 10:09
  • 1
    @duyduc27 it depends on how the form submit action is set up. In general, I would suggest using RequestParameter to read form post values.
    – sfdcfox
    Jun 14 at 11:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.