YouBIM.Common.HttpClient.Lib 9.0.14.1

dotnet add package YouBIM.Common.HttpClient.Lib --version 9.0.14.1
                    
NuGet\Install-Package YouBIM.Common.HttpClient.Lib -Version 9.0.14.1
                    
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="YouBIM.Common.HttpClient.Lib" Version="9.0.14.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="YouBIM.Common.HttpClient.Lib" Version="9.0.14.1" />
                    
Directory.Packages.props
<PackageReference Include="YouBIM.Common.HttpClient.Lib" />
                    
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 YouBIM.Common.HttpClient.Lib --version 9.0.14.1
                    
#r "nuget: YouBIM.Common.HttpClient.Lib, 9.0.14.1"
                    
#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 YouBIM.Common.HttpClient.Lib@9.0.14.1
                    
#: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=YouBIM.Common.HttpClient.Lib&version=9.0.14.1
                    
Install as a Cake Addin
#tool nuget:?package=YouBIM.Common.HttpClient.Lib&version=9.0.14.1
                    
Install as a Cake Tool

YouBIM.Common.HttpClient.Lib

Overview

YouBIM.Common.HttpClient.Lib is a helper library designed to simplify HTTP client operations in .NET applications. It abstracts the complexities of sending HTTP requests and handling responses, providing a consistent interface for GET, POST, PUT, PATCH, and DELETE operations. The library supports custom headers for different microservice types and includes built-in logging for improved traceability.

Features

  • Support for GET, POST, PUT, PATCH, and DELETE HTTP methods.
  • Configurable to handle requests for different microservice types (e.g., PHP and .NET).
  • Automatic inclusion of authorization headers.
  • Integrated error handling and logging.
  • JSON serialization/deserialization for seamless data handling.

Installation

Include the YouBIM.Common.HttpClient.Lib DLL in your .NET project by adding it as a reference or using a package manager (if available as a NuGet package).

dotnet add package YouBIM.Common.HttpClient.Lib

Usage

Initialization

To use the HttpClientHelper, ensure that IHttpClientFactory, IUserContextService, and ILogger are properly configured in your application:

services.AddHttpClient();
services.AddScoped<IHttpClientHelper, HttpClientHelper>();

Example Code

GET Request
var result = await httpClientHelper.GetAsync<MyResponseType>("https://api.example.com/data");
POST Request
var data = new MyRequestData { Property = "Value" };
var response = await httpClientHelper.PostAsync<MyResponseType, MyRequestData>("https://api.example.com/data", data);
PUT Request
var updateData = new MyUpdateData { Property = "UpdatedValue" };
var updatedResponse = await httpClientHelper.PutAsync<MyResponseType, MyUpdateData>("https://api.example.com/data/1", updateData);
PATCH Request
var patchData = new MyPatchData { Property = "PatchedValue" };
var patchedResponse = await httpClientHelper.PatchAsync<MyResponseType, MyPatchData>("https://api.example.com/data/1", patchData);
DELETE Request
var deleteResponse = await httpClientHelper.DeleteAsync<MyResponseType>("https://api.example.com/data/1");

Configuration

The library differentiates between microservice types using the MicroserviceType enum:

  • PHP: Uses the X-AUTH-TOKEN header.
  • DotNet: Uses the Bearer token for the Authorization header.

Error Handling

The HttpClientHelper handles common exceptions, such as HttpRequestException and TaskCanceledException, and logs detailed information for debugging purposes.

Contributing

Feel free to contribute by opening issues or submitting pull requests.

License

This project is licensed under the MIT License.

Contact

For questions or support, please contact support@youbim.com.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  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.

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
9.0.14.1 119 3/26/2026
9.0.14 116 3/20/2026
9.0.6 172 2/3/2026
1.0.1 212 11/5/2024
1.0.0 183 11/4/2024