In this post, let's have a look at dotnet-http-file, a small
.NET tool I put together that runs Visual Studio .http files
from the command line.
I use .http files a lot. They live next to the code, they are plain
text and they are easy to share. But they only run inside the IDE. I wanted to
run the same files from a terminal, from a script, on Windows, Linux or macOS,
without copying anything into another tool.
The tool reads the same syntax Visual Studio does: variables,
http-client.env.json environments, request variables and so on. It adds
one thing of its own: a provider that gets a Microsoft Entra access
token from your existing sign-in, so you don't have to paste tokens into
files.
Installing
It's on NuGet as a .NET global tool. It needs .NET 11, and the version
is 0.1.0 (latest as of today, it will change).
dotnet tool install --global dotnet-http-file
Running a request
Let's take a simple .http file against JSONPlaceholder Fake REST API.
@BaseUrl=https://jsonplaceholder.typicode.com # @name getToDos GET {{BaseUrl}}/todos?_limit=2 ### # @name getToDo GET {{BaseUrl}}/todos/{{getToDos.response.body.$[1].id}}
When the file has more than one request, it asks which one to run.
dotnet http-file Basics.http
You can directly pick the request by its name.
dotnet http-file Basics.http --name getToDo
That's the nice part. getToDo uses a value from getToDos, so the
tool sends getToDos first. In Visual Studio, you'd have to send it
yourself before this one.
No more pasting tokens
A lot of times, when calling Entra protected APIs, you will have to separately
run az account get-access-token, copy the token and paste it into
a @token variable. Then it expires within the hour and you do it again.
With dotnet-http-file, you put the scope in
http-client.env.json using the EntraAccessToken provider.
{
"dev": {
"GraphToken": {
"provider": "EntraAccessToken",
"scope": "https://graph.microsoft.com/.default"
}
}
}
And use it like any other variable.
# @name getMe
GET https://graph.microsoft.com/v1.0/me?$select=displayName,userPrincipalName
Authorization: Bearer {{GraphToken}}
Accept: application/json
dotnet http-file Entra.http --name getMe --env dev
The token comes from DefaultAzureCredential, so it works with whatever
you're already signed in with: az login, Visual Studio,
azd auth login and so on. Every run gets a fresh token, and the tool
never opens a browser. You can also add a tenantId when your account
lives in more than one tenant.
Using it in scripts
In a terminal, the tool prints the request, status, headers and the formatted
body, with secrets masked. When the output is piped, it writes only the raw
body to stdout, so it plays well with other tools.
dotnet http-file Basics.http --name getToDos | jq '.[0].title'
You can use --show with full, headers, status or
body to choose what gets printed.
A failed request gives a non-zero exit code, so it works as a quick smoke test
in a pipeline too.
The source and the samples are on GitHub. Give it a try, and if something in
your .http files doesn't work, please open an issue.
More read:
Hope this helps.
Happy Coding.
Regards,
Jaliya




