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
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Soenneker.Box.HttpClients" Version="11.0.200" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Soenneker.Box.HttpClients" Version="11.0.200" />
                    
Directory.Packages.props
<PackageReference Include="Soenneker.Box.HttpClients" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Soenneker.Box.HttpClients --version 11.0.200
                    
#r "nuget: Soenneker.Box.HttpClients, 11.0.200"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Soenneker.Box.HttpClients@11.0.200
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Soenneker.Box.HttpClients&version=11.0.200
                    
Install as a Cake Addin
#tool nuget:?package=Soenneker.Box.HttpClients&version=11.0.200
                    
Install as a Cake Tool

alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image alternate text is missing from this package README image

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

  • Get returns the same HttpClient for the lifetime of the registered wrapper.
  • Do not dispose the returned client. Let the dependency-injection container dispose IBoxOpenApiHttpClient and 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 Get applies to client initialization. Pass a token separately to every HTTP operation.
  • The default base address is https://api.box.com/2.0. Direct HttpClient calls 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 Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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
Loading failed

Updated Multiple NuGet packages