Request body from a file
Section titled “Request body from a file”The < operator includes the contents of an external file as the request body:
POST https://api.example.com/dataContent-Type: application/json
< ./payload.jsonFile paths can be absolute or relative to the .http file's location (or workspace root in VS Code). Visual Studio 2022 does not support file includes.
Variable substitution in included files
Section titled “Variable substitution in included files”VS Code REST Client and httpyac use <@ to indicate that variables within the included file should be resolved:
POST https://api.example.com/dataContent-Type: application/json
<@ ./template.jsonJetBrains resolves variables in included files by default. httpyac provides a # @injectVariables metadata tag to control this behavior for JetBrains compatibility.
An encoding can be specified in VS Code REST Client: <@latin1 ./file.xml
Multipart & uploads
Section titled “Multipart & uploads”All major implementations except Visual Studio 2022 support multipart form data using standard MIME boundary syntax:
POST https://api.example.com/uploadContent-Type: multipart/form-data; boundary=----FormBoundary
------FormBoundaryContent-Disposition: form-data; name="field1"
value1------FormBoundaryContent-Disposition: form-data; name="file"; filename="document.pdf"Content-Type: application/pdf
< ./document.pdf------FormBoundary--The < filepath within a multipart boundary references a binary file. The filename parameter in Content-Disposition determines whether the part is sent as a file upload or as form text.
JetBrains provides a live template shortcut mptr to quickly scaffold multipart requests.
Imports & cross-file execution
Section titled “Imports & cross-file execution”JetBrains: import and run
Section titled “JetBrains: import and run”import ./auth-requests.http
run ./auth-requests.http#loginRequestimport makes requests from another file available. run executes a specific named request or all requests in a file. Variables can be overridden:
run ./file.http#request (@var=value)httpyac: @import and @ref
Section titled “httpyac: @import and @ref”# @import ./shared.http# @ref loginRequest
GET https://api.example.com/protectedAuthorization: Bearer {{loginRequest.token}}# @import loads variables and named requests from another file. # @ref declares a dependency — the referenced request is executed if needed.
Other clients
Section titled “Other clients”kulala.nvim supports the JetBrains-compatible import and run syntax. VS Code REST Client and Visual Studio 2022 do not support cross-file imports or execution.
Saving responses
Section titled “Saving responses”Saving with >> and >>!
Section titled “Saving with >> and >>!”JetBrains introduced the >> operator for saving response bodies to files:
GET https://api.example.com/data
>> ./responses/data.json>> creates a new file, appending a numeric suffix (e.g., -1, -2) if the file already exists. >>! overwrites the file if it exists.
The >> syntax can be combined with response handler scripts. Variables can be used in paths.
VS Code REST Client provides UI-based save buttons instead of in-file syntax.
Comparing with <>
Section titled “Comparing with <>”JetBrains supports a <> response reference for comparing the current response against a previously saved response file:
GET https://api.example.com/data
<> ./expected-response.jsonThis is unique to JetBrains.
Client support
Section titled “Client support”Per-client support for every file operation: File Operations comparison.