Skip to content

.http syntax

Reqjet reads and writes the .http format that Visual Studio, VS Code REST Client and JetBrains IDEs use. Reqjet’s own extras are written as comments (# @reqjet.…), which other tools ignore, so your files stay portable.

@baseUrl = https://httpbin.org # a file variable
### Create an item # ### starts a request; the text after it is its title
# @name createItem # a name, for chaining
# @reqjet.assert status == 200 # a test (a plain comment to other tools)
POST {{baseUrl}}/anything
Content-Type: application/json
{ "id": "{{$guid}}", "at": "{{$datetime iso8601}}" }
  • The request line is a method, the URL and an optional HTTP/1.1. Any method works. A long query string can continue on the following lines, each starting with ? or &.
  • Headers follow, one per line. A blank line ends them, and the body follows.
  • Comments start with # or //. A comment that starts with # @ is a directive.
  • {{name}} is a variable. See Environments and variables and Built-in variables.
POST {{baseUrl}}/upload
Content-Type: application/json
< ./payload.json
Written as Sends
Text after the headers That text, with {{variables}} filled in.
< ./payload.json The file, unchanged. The path is relative to the .http file.
<@ ./payload.json The file, with {{variables}} filled in first.

Multipart uploads (Content-Type: multipart/form-data; boundary=…) can send files alongside form fields: a part’s content can be < ./photo.png or <@ ./note.txt.

GET {{baseUrl}}/report.csv
>> ./out/report.csv
  • >> path writes the response body to a file, relative to the .http file. If the file exists, the new one is report-1.csv, report-2.csv and so on.
  • >>! path overwrites the file instead.
  • Files are only saved inside the folder the requests are in. A path outside it is refused.

Basic, Digest, AWS and Windows sign-in are written as the Authorization header, in VS Code REST Client’s form, and Reqjet works out the real header when it sends the request. You can also choose them on a request’s Auth tab.

Authorization: Basic {{user}}:{{password}} # base64-encoded when sent
Authorization: Digest {{user}} {{password}} # answered when the server challenges
Authorization: AWS {{accessKey}} {{secretKey}} # AWS Signature Version 4
Authorization: NTLM CORP\ann {{password}} # Windows sign-in as someone else
Authorization: Negotiate # Windows sign-in as you (Kerberos or NTLM)
Authorization: Bearer {{$auth.token("my-api")}} # an OAuth 2.0 token

OAuth 2.0 profiles are set in the environment files.

GRAPHQL https://countries.trevorblades.com/graphql
query Country($code: ID!) {
country(code: $code) { name capital }
}
{ "code": "GB" }

Use the GRAPHQL method (JetBrains), or an X-REQUEST-TYPE: GraphQL header (VS Code REST Client). The body is the query, optionally followed by a blank line and a JSON object of variables.

### Price feed
WEBSOCKET wss://feed.example.com/prices
{ "subscribe": "EURUSD" }
=== wait-for-server
{ "subscribe": "GBPUSD" }
### Notifications
GET {{baseUrl}}/notifications
Accept: text/event-stream
  • WEBSOCKET connects and sends the body’s messages in order. === separates messages, and === wait-for-server waits for a message from the server before sending the next.
  • A request with Accept: text/event-stream is read as a stream of server-sent events.
< {%
request.variables.set("requestId", $random.uuid);
%}
GET {{baseUrl}}/me
X-Request-Id: {{requestId}}
> {%
client.test("Status is 200", () => client.assert(response.status === 200));
%}
  • < {% … %} before the request line is a pre-request script.
  • > {% … %} after the request is a response handler. > ./handler.js runs a handler from a file.
  • They use the JetBrains script API, and run in a sandbox with no access to your files.