Sitemap
The new control plane

“Identity is the new control plane”. Articles around Microsoft Entra ID, Entra External ID and Azure AD B2C. Click the “Archive” link at the bottom for more posts.

How to create a .http file from scratch

5 min read4 days ago

--

Image of http file
AI generated

All the .http posts are here.

An “.http” file is just a plain text file with the “.http” extension. It uses a simple syntax to define one or more HTTP requests that you can run directly from your editor.

Syntax

  • Variables (optional, reusable values)

Define variables at the top of the file and reference them later with “{{name}}”:

@baseUrl = https://graph.microsoft.com/v1.0
@token = eyJ…
  • A request block

A request starts with an HTTP method and URL, followed by optional headers, a blank line, and then an optional body:

GET {{baseUrl}}/me
Authorization: Bearer {{token}}
Accept: application/json
  • Separating multiple requests

Use a line containing “###” to separate independent requests within the same file:

### Get my profile
GET {{baseUrl}}/me
Authorization: Bearer {{token}}
### Create something
POST {{baseUrl}}/me/sendMail
Authorization: Bearer {{token}}
Content-Type: application/json
{
"message": {
"subject": "Test",
"body": { "contentType": "Text", "content": "Hello" },
"toRecipients": [{ "emailAddress": { "address": "someone@example.com" } }]
}
}

Key syntax rules

- “# comment” or “// comment” — comment lines
- “@name = value” — define a variable reference with “{{name}}”
- “###” on its own line — separates independent requests in the same file
- Method + URL on one line (“GET”, “POST”, “PUT”, “DELETE”, etc.)
- Headers go on the lines right after, one per line (“Header-Name: value”)
- A blank line separates headers from the request body (if any)

Running the file

  • For VS Code, install the “REST Client” extension (humao.rest-client), then click the “Send Request” CodeLens link that appears above each request, or press “Ctrl+Alt+R” with the cursor inside a request block
  • For Visual Studio 2026, “.http" files are supported natively via the built-in
    HTTP editor — just open the file and click the run/send icon next to each request.

No special tooling is required to create the file — only to execute the requests inside it.

How does this compile?

An “.http” file is not source code — it isn’t parsed into an assembly, isn’t type-checked, and has no build step. It’s a plain-text description of raw HTTP requests, so a compiler has nothing to produce.

  • No syntax requires compilation — the “@variable”, “###”, method/URL, headers, and body are just text that the editor’s HTTP client (REST Client in VS Code, or the built-in HTTP editor in Visual Studio) reads and sends over the wire at the moment you click “Send Request”
  • No project reference or assembly output — unlike “.cs”/”.vb” files, “.http” files aren’t included in a project’s build (“.csproj”) compilation pass, so adding, editing, or saving one never triggers (or breaks) a build
  • Execution happens live— each time you click “Send Request”, the tool substitutes variables (“{{baseUrl}}”, “{{token}}”, etc.) and fires the literal HTTP request immediately. There’s no intermediate step that transforms the file into something else first
  • Instant edit-and-retry loop — because nothing is compiled, you can change the URL, header, or body text and resend the request right away without waiting for a build or restarting any process

In short, “.http” files are interpreted on the spot by your editor’s HTTP client, the same way a “curl” command or Postman request is “run” rather than “built”

Get Rory Braybrook’s stories in your inbox

Join Medium for free to get updates from this writer.

Here’s an example:

# How to get an access token from Microsoft Graph Explorer:
# 1. Go to https://developer.microsoft.com/graph/graph-explorer
# 2. Sign in (top-left "Sign in" button) with the account you want to call
# Graph as.
# 3. Consent to the permissions you need (e.g. User.Read) when prompted.
# 4. Run any query (e.g. GET /me) by clicking "Run query".
# 5. Copy the token: Check the response panel's "Access token" tab if your
# version of Graph Explorer shows one.
# 6. Paste the copied token below as the value of the "token" variable
# (replacing the old one).
# NOTE: Tokens expire after ~1 hour, so you'll need to repeat this when it
# expires.

# How to send this request from VS Code:
# 1. Install the "REST Client" extension (humao.rest-client) from the
# Extensions marketplace.
# 2. Open this .http file in VS Code.
# 3. Click the "Send Request" link that appears above the GET line (CodeLens),
# or place your cursor in the request block and press Ctrl+Alt+R.
# 4. The response opens in a side pane in VS Code.
# 5. If you update the token or base URL variables, just re-click
# "Send Request" to pick up the change.

@baseUrl = https://graph.microsoft.com/v1.0
@token = ey...sA
### Get the signed-in user's profile
GET {{baseUrl}}/me
Authorization: Bearer {{token}}
Accept: application/json

### Get the signed-in user's direct reports
GET {{baseUrl}}/me/directReports
Authorization: Bearer {{token}}
Accept: application/json

### Get more details about the signed-in user (select additional properties)
GET {{baseUrl}}/me?$select=displayName,givenName,surname,mail,
userPrincipalName,jobTitle,department,officeLocation,mobilePhone,
businessPhones,preferredLanguage
Authorization: Bearer {{token}}
Accept: application/json

Sadly, there doesn't seem to be any syntax to automatically pop up a login screen 😢 to get the access token.

The easiest way to get an access token is to use Graph Explorer, log in with the user, run a request and then copy the access token into the “@token = ey…sA” line in the script above.

Press enter or click to view image in full size

VS automatically adds the “Send request” commands. That’s why you don’t see them in the samples I’ve included.

Press enter or click to view image in full size

Running, e.g. the first command shows:

Press enter or click to view image in full size

A common pattern is to use some variable returned in the previous response in the next request.

As an example:

### Get more details about the signed-in user (select additional properties)
# @name meDetails
GET {{baseUrl}}/me?$select=displayName,givenName,surname,mail,
userPrincipalName,jobTitle,department,officeLocation,mobilePhone,
businessPhones,preferredLanguage
Authorization: Bearer {{token}}
Accept: application/json

### Look up the same user by userPrincipalName (uses the value from the
previous response)
# NOTE: Send the "meDetails" request above at least once before sending this
# one, so Visual Studio has a cached response to pull
# userPrincipalName from
GET {{baseUrl}}/users/{{meDetails.response.body.$.userPrincipalName}}
Authorization: Bearer {{token}}
Accept: application/json

The first request (which we reference as “@name meDetails”) returns userPrincipalName, which we use in the second request.

Note: I used AI to write the VS Code parts, as I don’t use VS Code very often.

All good!

--

--

Rory Braybrook

Written by Rory Braybrook

NZ Microsoft Identity dude and MVP. Entra ID/Entra External ID/Azure AD B2C/VC. StackOverflow: https://bit.ly/2XU4yvJ Presentations: http://bit.ly/334ZPt5

The new control plane

Published in The new control plane

“Identity is the new control plane”. Articles around Microsoft Entra ID, Entra External ID and Azure AD B2C. Click the “Archive” link at the bottom for more posts.