Inline variable definition
Section titled “Inline variable definition”Variables are defined directly in the .http file using the @ prefix:
@hostname = api.example.com@port = 8080@baseUrl = https://{{hostname}}:{{port}}The @name = value syntax is supported by all major implementations. Variables can reference other variables in their definitions.
Variable names must not contain spaces. VS Code REST Client requires a complete line per definition with whitespace trimmed.
Lazy variables
Section titled “Lazy variables”httpyac introduces a distinction between fixed variables (evaluated at parse time, using =) and lazy variables (evaluated at execution time, using :=):
@eager = {{$timestamp}}@lazy := {{$timestamp}}The eager variable captures the timestamp once when the file is parsed. The lazy variable generates a fresh timestamp each time it's used.
Variable substitution
Section titled “Variable substitution”All implementations use double curly braces for variable substitution:
GET https://{{hostname}}/api/{{version}}/usersAuthorization: Bearer {{token}}The {{variableName}} syntax is universal.
Percent-encoding substitution
Section titled “Percent-encoding substitution”VS Code REST Client supports {{%variableName}} which URL-encodes the variable value before substitution.
Variable scoping and precedence
Section titled “Variable scoping and precedence”Variable resolution order differs between implementations:
VS Code REST Client (highest to lowest):
- Request variables (named request responses)
- File variables (
@var = value) - Prompt variables (
@prompt) - Environment variables (from
settings.json)
JetBrains (highest to lowest):
- Per-request variables (set in pre-request scripts)
- In-place file variables (
@var = value) - Global variables (
client.global.set()) - Environment variables (from
http-client.env.json)
httpyac (highest to lowest):
- Request-scoped variables
- File-global variables
- Environment variables (from
.env,http-client.env.json, or config files)
Named request variables (response chaining)
Section titled “Named request variables (response chaining)”Responses from named requests can be referenced as variables. The syntax differs significantly between implementations.
# @name login
POST https://api.example.com/auth
Content-Type: application/json
{"username": "admin", "password": "secret"}
###
GET https://api.example.com/protected
Authorization: Bearer {{login.response.body.$.token}}
POST https://api.example.com/auth
Content-Type: application/json
{"username": "admin", "password": "secret"}
> {%
client.global.set("auth_token", response.body.token);
%}
###
GET https://api.example.com/protected
Authorization: Bearer {{auth_token}}
# @name login
POST https://api.example.com/auth
###
# @ref login
GET https://api.example.com/protected
Authorization: Bearer {{login.token}}
VS Code REST Client uses dot-path notation with these reference patterns:
{{name.response.body.$.jsonPath}}— JSONPath into JSON response{{name.response.body.//xpathExpr}}— XPath into XML response{{name.response.body.*}}— entire response body{{name.response.headers.Header-Name}}— response header value{{name.request.body.*}}— original request body
JetBrains uses response handler scripts to store values in global variables, then references them as {{variableName}}. There is no direct dot-path syntax.
httpyac supports the # @name / # @ref pattern, where a named request's parsed response body becomes available as a variable.
Visual Studio 2022 (since v17.12) supports VS Code REST Client-style request variables.
| Feature | VS Code | JetBrains | httpyac | VS 2022 | kulala |
|---|---|---|---|---|---|
| Inline variable definition (@var = value) | |||||
| Variable substitution ({{variableName}}) | |||||
| Percent-encoding substitution ({{%var}}) URL-encodes the variable value. Unique to VS Code REST Client. | |||||
| Lazy variables (@var := value) Evaluated at execution time rather than parse time. | |||||
| Named request response chaining Syntax differs: VS Code uses dot-path ({{name.response.body.$.path}}), JetBrains uses script-based global variables, httpyac uses @ref. | |||||
| Environments in settings.json | |||||
| http-client.env.json | |||||
| http-client.private.env.json | |||||
| http-client.env.json.user Microsoft-specific override file. | |||||
| .env dotenv files VS Code REST Client and VS 2022 support via {{$dotenv NAME}} accessor. httpyac and kulala parse .env files natively. | |||||
| JS/JSON config file httpyac.config.js or .httpyac.js | |||||
| $shared environment | |||||
| Secrets providers (Azure Key Vault, etc.) ASP.NET Core User Secrets, Azure Key Vault, DPAPI. |