Soenneker.Box.HttpClients
11.0.200
Prefix Reserved
dotnet add package Soenneker.Box.HttpClients --version 11.0.200
NuGet\Install-Package Soenneker.Box.HttpClients -Version 11.0.200
<PackageReference Include="Soenneker.Box.HttpClients" Version="11.0.200" />
<PackageVersion Include="Soenneker.Box.HttpClients" Version="11.0.200" />
<PackageReference Include="Soenneker.Box.HttpClients" />
paket add Soenneker.Box.HttpClients --version 11.0.200
#r "nuget: Soenneker.Box.HttpClients, 11.0.200"
#:package Soenneker.Box.HttpClients@11.0.200
#addin nuget:?package=Soenneker.Box.HttpClients&version=11.0.200
#tool nuget:?package=Soenneker.Box.HttpClients&version=11.0.200
Soenneker.Box.HttpClients
Provides a reusable HttpClient configured for the Box API and dependency injection.
Installation
dotnet add package Soenneker.Box.HttpClients
Configuration
{
"Box": {
"ApiKey": "<Box access token>",
"ClientBaseUrl": "https://api.box.com/2.0",
"AuthHeaderName": "Authorization",
"AuthHeaderValueTemplate": "Bearer {token}"
}
}
Only Box:ApiKey is required. The other values above show their defaults. {token} in AuthHeaderValueTemplate is replaced with the configured value.
Keep the access token in a secret provider rather than source control or a checked-in settings file.
Registration
using Microsoft.Extensions.DependencyInjection;
using Soenneker.Box.HttpClients.Registrars;
services.AddBoxOpenApiHttpClientAsSingleton();
AddBoxOpenApiHttpClientAsScoped() creates one wrapper and cached client per dependency-injection scope.
Usage
using Soenneker.Box.HttpClients.Abstract;
public sealed class BoxProfileClient
{
private readonly IBoxOpenApiHttpClient _boxHttpClient;
public BoxProfileClient(IBoxOpenApiHttpClient boxHttpClient)
{
_boxHttpClient = boxHttpClient;
}
public async ValueTask<string> GetCurrentUser(
CancellationToken cancellationToken)
{
HttpClient client = await _boxHttpClient.Get(cancellationToken);
using HttpResponseMessage response = await client.GetAsync(
"/2.0/users/me",
cancellationToken);
response.EnsureSuccessStatusCode();
return await response.Content.ReadAsStringAsync(cancellationToken);
}
}
For generated-client usage, pair this package with Soenneker.Box.OpenApiClientUtil rather than issuing HTTP requests directly.
Lifecycle and behavior
Getreturns the sameHttpClientfor the lifetime of the registered wrapper.- Do not dispose the returned client. Let the dependency-injection container dispose
IBoxOpenApiHttpClientand its cache entry. - Configuration is read when the client is first created. Later configuration changes do not rebuild that cached client.
- The cancellation token passed to
Getapplies to client initialization. Pass a token separately to every HTTP operation. - The default base address is
https://api.box.com/2.0. DirectHttpClientcalls should use an appropriate Box API path; the example uses a root-relative/2.0/...path. - Non-success responses are not converted to domain exceptions by this wrapper. Use
EnsureSuccessStatusCode, inspect the response, or use the generated OpenAPI client.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Soenneker.Extensions.Configuration (>= 11.0.921)
- Soenneker.Utils.HttpClientCache (>= 11.0.2188)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on Soenneker.Box.HttpClients:
| Package | Downloads |
|---|---|
|
Soenneker.Box.OpenApiClientUtil
A thread-safe utility for obtaining Box's OpenApiClient singleton. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 11.0.200 | 63 | 12/3/2026 |
| 11.0.199 | 55 | 12/3/2026 |
| 11.0.198 | 56 | 12/3/2026 |
| 11.0.197 | 51 | 12/3/2026 |
| 11.0.196 | 59 | 12/3/2026 |
| 11.0.195 | 67 | 12/2/2026 |
| 11.0.193 | 64 | 12/2/2026 |
| 11.0.192 | 96 | 12/2/2026 |
| 11.0.191 | 92 | 12/2/2026 |
| 11.0.190 | 97 | 12/2/2026 |
| 11.0.189 | 87 | 12/1/2026 |
| 11.0.188 | 103 | 12/1/2026 |
| 11.0.187 | 103 | 12/1/2026 |
| 11.0.186 | 100 | 12/1/2026 |
| 11.0.185 | 101 | 11/30/2026 |
| 11.0.184 | 95 | 11/30/2026 |
| 11.0.183 | 122 | 11/30/2026 |
| 11.0.182 | 108 | 11/29/2026 |
| 11.0.181 | 94 | 11/29/2026 |
| 11.0.180 | 154 | 11/19/2026 |
Updated Multiple NuGet packages