Send requests from .http files in VS Code with your team's environments

.http files are a nice way to keep a few requests next to the code: plain text, reviewed in pull requests, no tool needed to read them. The trouble starts when a request needs a token from the staging environment, or the same auth and headers as the team's collection. The Requestarium VS Code extension sends .http and .rest files with your shared environments and scripts, without converting them into anything.

Send one

Open any .http file. Above each request there's a ▶ Send with Requestarium link:

api.http
@baseUrl = {{stagingUrl}}

### Get the current user
GET {{baseUrl}}/me
Authorization: Bearer {{token}}

### Create an order
POST {{baseUrl}}/orders
Content-Type: application/json

{ "sku": "BOOK-42", "quantity": 1 }

Click it, and the response, test results and console output open in an editor tab. The request is sent from your machine, so localhost, docker-compose and VPN-only hosts work.

Where the variables come from

  1. The file's own @name = value lines;
  2. the active environment, chosen in the Env tab of the Requestarium view;
  3. a local .env file, if you loaded one with Requestarium: Load .env File….

So {{token}} resolves to the staging token for whoever has Staging selected, and nothing secret has to be written in the file. A teammate who switches to Local sends the same file to their own machine.

Run it like a collection request

Most collections set auth, headers or a pre-request script once at the collection or folder level. Link the file to one and every request in it runs inside that scope:

orders.http
# @requestarium-collection Orders API
# @requestarium-folder Admin/Refunds

### Refund an order
POST {{baseUrl}}/orders/{{orderId}}/refund

The collection's and folder's scripts run first, then the file's own pre-request handler, the request, and its response handler. The collection is matched by name or id; a missing one is an error, not a silent fallback.

Chain requests

Name a request, and later requests in the same file can read its response, the REST Client way:

HTTP
# @name login
POST {{baseUrl}}/login
Content-Type: application/json

{ "email": "[email protected]", "password": "{{qaPassword}}" }

###
GET {{baseUrl}}/me
Authorization: Bearer {{login.response.body.$.token}}

{{login.response.headers.X-Request-Id}} reads a header. Send login first; otherwise you get a clear message saying so.

JetBrains-style handlers (> {% client.test(...) %}) and handler files (> ./check-order.js) run too, in the same sandbox as collection scripts, with the pm API available.

When a file should become a collection

.http files stay great for a handful of requests one person maintains. When QA, CI runs or a mock server need them, import the file into a collection. You can export it back to .http later.

If you'd rather not see the links, turn off requestarium.httpFileCodeLens in settings.