Rider's HTTP Client: Environment-Driven API Testing Without Leaving Your IDE
Rider's HTTP Client handles environments, OAuth flows, and symbol-driven request generation inside the IDE — replacing Postman for most .NET API workflows. Includes a complete token-refresh example and honest limitations.
22 Mar 2026, 11:48 UTC

The Problem: Context Switching Kills API Development Flow
You're debugging a failing integration test. The API returns 401. You switch to Postman, recreate the request, paste the token, realize the base URL is wrong, update it, run again — then switch back to Rider to fix the controller. Ten minutes later you've lost the thread of the actual bug.
Rider's built-in HTTP Client eliminates this round-trip. It lives inside the same editor where you write controllers, shares your project's symbol knowledge, and version-controls alongside your code. This post walks through the practical decisions that make it a viable replacement for external tools — and where it still falls short.
Environment Files: One Request File, Three Targets
The declarative .http syntax is straightforward, but the real power sits in .http.env.json. Define named environments once; switch via the toolbar dropdown without touching request files.
// .http.env.json
{
"local": {
"baseUrl": "https://localhost:7042",
"apiKey": "dev-key-123"
},
"staging": {
"baseUrl": "https://api-staging.example.com",
"apiKey": "{{stagingApiKey}}"
},
"production": {
"baseUrl": "https://api.example.com",
"apiKey": "{{prodApiKey}}"
}
}
Requests reference variables with {{variable}} syntax:
GET {{baseUrl}}/api/orders
Authorization: Bearer {{apiKey}}
Accept: application/json
Secrets stay out of VCS through .http.env.json.local (git-ignored by default). Each developer keeps their own staging/production keys locally while sharing the request structure.
Symbol-Driven Request Generation
In an ASP.NET Core project, type # inside a .http file. Rider's completion shows controller actions with route templates, HTTP methods, and parameter placeholders derived from the actual C# signatures.
// Typing #OrdersController.GetOrder generates:
GET {{baseUrl}}/api/orders/{id}
Accept: application/json
###
// Typing #OrdersController.CreateOrder generates:
POST {{baseUrl}}/api/orders
Content-Type: application/json
{
"customerId": "{{customerId}}",
"items": [
{
"productId": "{{productId}}",
"quantity": 1
}
]
}
Refactor the route in C# — the next completion reflects the change. No manual sync needed.
Worked Example: OAuth 2.0 Flow with Token Refresh
Response handlers (JavaScript/TypeScript) run after each response. They can extract tokens, assert status codes, and write variables into the environment for subsequent requests. Here's a complete OAuth Authorization Code flow with PKCE and automatic refresh.
// auth.http
@authHost = https://auth.example.com
@clientId = my-client
@redirectUri = http://localhost:5000/callback
### Step 1: Start authorization (run once, copy code from browser)
GET {{authHost}}/authorize?response_type=code&client_id={{clientId}}&redirect_uri={{redirectUri}}&scope=api.read&code_challenge=E9Melhoa2OwvFrEMTJguCHaoeK1t8URWbuGJSstw-cM&code_challenge_method=S256
### Step 2: Exchange code for tokens
POST {{authHost}}/token
Content-Type: application/x-www-form-urlencoded
grant_type=authorization_code&code={{authCode}}&client_id={{clientId}}&redirect_uri={{redirectUri}}&code_verifier=dBjftJeZ4CVP-mB92K27uhbUJU1p1r_wW1gFWFOEjXk
>
{% client.test("Token exchange succeeded", function() {
client.assert(response.status === 200);
const tokens = response.body;
client.global.setVariable("accessToken", tokens.access_token);
client.global.setVariable("refreshToken", tokens.refresh_token);
client.global.setVariable("expiresAt", Date.now() + tokens.expires_in * 1000);
}); %}
### Step 3: Call protected API (auto-refreshes if expired)
GET {{baseUrl}}/api/me
Authorization: Bearer {{accessToken}}
>
{%
const expiresAt = client.global.getVariable("expiresAt") || 0;
if (Date.now() >= expiresAt - 30000) { // refresh 30s early
const refreshToken = client.global.getVariable("refreshToken");
const refreshResponse = client.request({
url: "{{authHost}}/token",
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: `grant_type=refresh_token&refresh_token=${refreshToken}&client_id={{clientId}}`
});
client.test("Token refreshed", function() {
client.assert(refreshResponse.status === 200);
const newTokens = refreshResponse.body;
client.global.setVariable("accessToken", newTokens.access_token);
client.global.setVariable("refreshToken", newTokens.refresh_token);
client.global.setVariable("expiresAt", Date.now() + newTokens.expires_in * 1000);
});
}
%}
Run Step 2 once after pasting the authCode from the browser. Step 3 thereafter handles refresh transparently. Variables persist across Rider sessions in the Variables tool window.
Trade-offs and Current Limits
- No collection runner. You cannot execute multiple
.httpfiles sequentially or in parallel from the UI. CI pipelines need external tooling (e.g.,dotnet-http-clientor custom Node scripts). - Environment variables don't substitute inside response handlers.
{{baseUrl}}works in request URLs/headers/body but not inclient.request({ url: "{{baseUrl}}/..." }). Useclient.global.getVariable("baseUrl")instead. - Large multipart uploads (>100 MB) freeze the UI. Streaming uploads aren't supported; use
curlor a dedicated client for heavy payloads. - GraphQL support is basic. No introspection-driven autocompletion or variable validation like Altair/Postman provide.
- WSL2 localhost quirk. When Rider runs on Windows but the backend runs in WSL2,
localhostinbaseUrlresolves to the Windows host. Usehost.docker.internalor the WSL IP (checkip addr show eth0).
Verification Checklist
- Open Rider → New File → HTTP Request. Confirm syntax highlighting, code completion for HTTP methods/headers, and the green Run gutter icon appear.
- Create
.http.env.jsonwithlocalandstagingentries. Switch via the environment dropdown in the editor toolbar; verify{{baseUrl}}resolves correctly. - Add a response handler using
client.testandclient.global.setVariable. Run the request; open View → Tool Windows → HTTP Client Variables to see persisted values. - In an ASP.NET Core project, type
#in a.httpfile. Confirm controller actions appear with correct routes and parameter placeholders. - Check Help → About for Rider version. Response handler API changed in 2023.2 (
client.log→console.log, newclient.global.setVariable). Update older scripts accordingly.
Closing Action
Move one authenticated API workflow from your external client into a .http file this week. Keep the environment file in VCS, add .http.env.json.local to .gitignore, and share the request file with a teammate. The first time they run it against staging without asking "what's the base URL again?" you'll see the payoff.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.