Get HTTP Param
The Get HTTP Param block reads one value from the request's URL and passes it to the next block. It can read a query parameter (?page=2) or a part of the path (/users/123).
When to use it
- Read an id from the path, like
123in/users/123. - Read options from the query string, like
page,limitorsearch. - Don't use it for data sent in the body. Use Get HTTP Request Body.
- Don't use it for headers or cookies. Use Get HTTP Header or Get Request Cookie.
Inputs
| Field | Required | Default | What it does |
|---|---|---|---|
| Mode | No | Single | Single handles one value. Multiple handles a list of rows, see below. |
| Name | Yes | none | The name of the parameter. Can be a JS expression. |
| Source | Yes | none | query: look after the ? in the URL. path: look in the route's path parameters. |
For path, the name is the one you gave the route, for example id for a route like /users/:id.
Outputs
| Handle | When it is used |
|---|---|
| Next (right) | Always. The next block receives the value as text. |
Example
The route is /users/:id and the caller requests /users/123?verbose=true.
| Name | Source | The next block receives |
|---|---|---|
id | path | "123" |
verbose | query | "true" |
Single or Multiple
Pick Multiple to read several parameters in one block. Each row has a Source (query or path) and a Name.
- The output is an array with one value per row, in row order.
- A missing parameter gives
""for its row. The other rows still work.
For /users/42?tab=posts:
| Source | Name |
|---|---|
| Path | id |
| Query | tab |
The next block receives ["42", "posts"].
How it behaves
- Always text.
"123"is not the number123. Convert it with a Transformer or JS when you need a number. - A missing value is empty text. If the parameter isn't there, the value is
"". It is not an error. - It replaces the flowing data. The next block's
inputis the value, not what came before. Store earlier data first with Set Variable. - Wrong source, empty result. A path parameter read with Source
query(or the other way round) comes back empty.
Related blocks
- Get HTTP Request Body: read data sent in the body.
- Get HTTP Header: read a header.
- If Condition: check that a required value is present.
- DB Get Single: look up a record by the id you just read.
