Find missing variables before you send a request
GET {{baseUrl}}/users/{{userId}} looks fine until userId isn't set and the request goes to /users/ and lists everyone. Or {{token}} is empty and you spend ten minutes debugging a 401 that's really a missing variable.
Requestarium shows you which variables a request uses, and stops before sending when one has no value.
The Variables panel
Open a request and the Variables panel. For each {{variable}} in the URL, headers, body, auth and settings, it shows:
- the name;
- whether it's defined;
- a preview of its value (secret values are masked);
- its source: inherited (collection or folder), environment, global, or built-in.
A missing variable stands out before you press Send. So does one that comes from a surprising place: a baseUrl that's set on a folder and silently overrides the environment's.
Where values come from
From lowest to highest priority, roughly:
- collection variables, then folder variables (outer to inner);
- the selected environment;
- a local
.envfile you loaded (it overrides the environment for your session); - values set by scripts earlier in the run;
- in the CLI, values from the command line:
--env-file,--env-var,--var.
Dynamic variables such as {{$guid}}, {{$timestamp}} and {{$randomEmail}} are always available. See the dynamic variables reference.
What happens when one is missing
In the CLI, a request with an unresolved variable is not sent. It's reported as an error that names the missing variables (Missing variables: {{userId}}).
The JSON report lists them in missingVariables and the error has the code unresolved_variables, so a CI job can tell "the API is broken" from "the run is misconfigured":
requestarium run-collection "Users API" --env Staging --json \
| jq -r '.results[] | select(.error.code == "unresolved_variables") | "\(.path): \(.missingVariables | join(", "))"'The fix is one of:
- add the variable to the environment, or pick another
--env; - pass it for this run:
--var userId=42; - make sure the script that should set it runs earlier (for example, the login is before the requests that need its token).
Literal braces
Some APIs use {{…}} themselves: templating services, email providers with Handlebars bodies. In a request's Settings, turn off Resolve variables before send and the text is sent as written. That's per request, so the rest of the collection still checks its variables.
A variable that's set, but wrong
Missing is the easy case. For "set, but not to what I expected", print what the script sees:
console.log('env', pm.environment.get('baseUrl'), 'merged', pm.variables.get('baseUrl'));If they differ, something with a higher priority is winning. See debugging scripts with console.log.
Missing in another environment
Test suites warn when a variable their requests use, such as {{host}}, isn't set in the picked environment but is set in another one, and offer to switch. Variables that a script or a Save to variable step sets don't count, since they'll exist at run time.