Tolitech.HttpClients
1.0.0-preview.5
This is a prerelease version of Tolitech.HttpClients.
dotnet add package Tolitech.HttpClients --version 1.0.0-preview.5
NuGet\Install-Package Tolitech.HttpClients -Version 1.0.0-preview.5
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="Tolitech.HttpClients" Version="1.0.0-preview.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Tolitech.HttpClients" Version="1.0.0-preview.5" />
<PackageReference Include="Tolitech.HttpClients" />
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 Tolitech.HttpClients --version 1.0.0-preview.5
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Tolitech.HttpClients, 1.0.0-preview.5"
#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 Tolitech.HttpClients@1.0.0-preview.5
#: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=Tolitech.HttpClients&version=1.0.0-preview.5&prerelease
#tool nuget:?package=Tolitech.HttpClients&version=1.0.0-preview.5&prerelease
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Tolitech.HttpClients
Tolitech.HttpClients is a generic HTTP client implementation based on the abstractions from the previous project. It provides a powerful base class (BaseHttpClient
) to perform HTTP operations (GET, POST, PUT, PATCH, DELETE) in a structured, safe, and efficient way.
Key Features
- Generic implementation for HTTP clients.
- Native support for JSON (serialization/deserialization).
- Custom header management.
- HTTP response validation and error handling.
- Direct integration with Tolitech.HttpClients.Abstractions contracts.
Main Class Structure
BaseHttpClient
The base class provides methods such as:
GetAsync<TResponse>()
: Performs a GET request.PostAsync<TRequest, TResponse>()
: Performs a POST request.PutAsync<TRequest, TResponse>()
: Performs a PUT request.PatchAsync<TRequest, TResponse>()
: Performs a PATCH request.DeleteAsync<TResponse>()
: Performs a DELETE request.
Implementation Example
public class MyHttpClient : BaseHttpClient
{
public MyHttpClient(HttpClient httpClient) : base(httpClient) { }
public async Task<Result<MyResponse>> GetMessageAsync(string url)
{
return await GetAsync<MyResponse>(url);
}
}
How to Use
HttpClient client = new HttpClient();
var service = new MyHttpClient(client);
var result = await service.GetMessageAsync("https://api.example.com/message");
if (result.IsSuccess)
{
Console.WriteLine(result.Value.Message);
}
else
{
Console.WriteLine($"Error: {result.Detail}");
}
Advanced Examples
Sending POST Requests with Body and Headers
var body = new MyRequest { Name = "John" };
var headers = new Dictionary<string, string> { { "Authorization", "Bearer token" } };
var result = await service.PostAsync<MyRequest, MyResponse>(
"https://api.example.com/message",
body,
headers
);
Error Handling and Custom Responses
if (!result.IsSuccess)
{
Console.WriteLine($"Status: {result.StatusCode}");
Console.WriteLine($"Detail: {result.Detail}");
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net9.0
- Tolitech.HttpClients.Abstractions (>= 1.0.0-preview.3)
- Tolitech.Results (>= 1.0.0-preview.4)
- Tolitech.Results.Http (>= 1.0.0-preview.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last Updated |
---|---|---|
1.0.0-preview.5 | 48 | 7/18/2025 |
1.0.0-preview.4 | 112 | 7/3/2025 |
1.0.0-preview.3 | 110 | 7/2/2025 |
1.0.0-preview.2 | 149 | 2/17/2025 |
1.0.0-preview.1 | 71 | 1/29/2025 |