EssentialLayers.Request 1.5.7

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

Essential Layers

EssentialLayers.Request

Is a complement to the package EssentialLayers to provide an extra layer for using http requests in an easy way.

Configure

Add the dependencies in your Program.cs file

builder.Services.UseRequest();

And then set the options (Optional)

app.Services.ConfigureRequest(
	new HttpOption
	{
		BaseUri = "https/api.dev",
		AppName = "MyApi",
		AppVersion = "v1",
		InsensitiveMapping = true
	}
);

If you want manage multiple instances of the same service, you can use the following code:

  1. Inject the IHttpService or IRequestService
  2. Set configs on runtime
yourService.SetOptions(
	new HttpOption
	{
		BaseUri = YOUR_BASE_URI,
		Token = YOUR_TOKEN
	}
);

🚀 New Feature: IHttpFactory

IHttpFactory is the new provider to send request toward multiple apis.

To start to use, add the next section in your appsettings.json

"HttpClients": {
	"AuthApi": {
		"BaseUrl": "https://localhost:5000/api/",
		"UserAgent": "FirstApiClient/1.0", (Optional) => Default 'MyApp/1.0'
		"ContentType": "application/json" (Optional) => Default 'application/json'
	}
	"SecondApiClient": {
		"BaseUrl": "https://localhost:5001/api/",
		"UserAgent": "SecondApiClient/1.0", (Optional) => Default 'MyApp/1.0'
		"ContentType": "application/json" (Optional) => Default 'application/json'
	}
}

In your Program.cs file

builder.Services.AddHttpClients(builder.Configuration);
builder.Services.ConfigureFactory();

OR

In your Program.cs file

services.AddTransient<AuthHeaderHandler>();

services.AddHttpClient(
	clientName, (client) =>
	{
		client.BaseAddress = new Uri("https://localhost:5000/api/");
		client.DefaultRequestHeaders.UserAgent.ParseAdd("AuthApi/1.0");
		client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
	}
).AddHttpMessageHandler<AuthHeaderHandler>();

services.AddHttpClient(
	clientName, (client) =>
	{
		client.BaseAddress = new Uri("https://localhost:5001/api/");
		client.DefaultRequestHeaders.UserAgent.ParseAdd("SecondApiClient/1.0");
		client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
	}
).AddHttpMessageHandler<AuthHeaderHandler>();

builder.Services.ConfigureFactory();

And in your specific service.cs file

public class AuthService (IHttpFactory httpFactory)
	{
		private const string CLIENT_NAME = "AuthApi";

		public Task<HttpResponse<LoginResponseDto>> LoginAsync(string userName, string password)
		{
			return httpFactory.PostAsync<LoginResponseDto, LoginRequestDto>(
				CLIENT_NAME, "User/Login", new LoginRequestDto(userName, password)
			);
		}
	}

	public record LoginRequestDto(string UserName, string Password);

	public record LoginResponseDto(UserDto? User, string Token);

	public record UserDto(string Id, string Email, string Name, string PhoneNumber);
Release Notes
  • Removed FactoryTokenProvider as a singleton 31-10-2025
  • Implemented the IHttpFactory as a stateless, passing as parameter the clientName 24-10-2025
  • The response from all methods has changed from ResultHelper<T> to HttpResponse<T> to keep compatibility 23-10-2025
  • Now instead of clienName the key will be taking as a clientName 22-10-2025
  • Read multiple http clients from the appsettings.json 22-10-2025
  • "HttpFactoryOptions" configuration binded correctly 22-10-2025
  • It was solved "Unable to resolve service for type 'EssentialLayers.Request.Services.Factory.IFactoryTokenProvider" issue 21-10-2025
  • New provider based in IHttpClientFactory implementation to send requests 21-10-2025
  • Updating of dependencies to the last version 14-10-2025
  • In the model HttpOption, must be add an extra property to send the headers since ConfigureRequest 09/10/2025
  • Updating of nuget packages EssentialLayers and Microsoft.Extensions.Http 27/08/2025
  • Remove repeated headers 17-07-2025
  • Now all methods of RequestService & RequestHelper allows nullable results; It was fixed issue in uribase 21-05-2025
  • New Delete method in HttpService only with url 16-04-2025
  • Reverted dependency type from Scoped to Singleton; Because always allows the overriding of base uri 14-04-2025
  • Now, the status "Created" is considered to be a successful response and "Unauthorized" to notify by message "Unauthorized" 14/04/2025
  • Reverted dependency type from Singleton to Scoped to allow multiple instances of the same service 05-03-2025
  • The HttpService and RequestService classes are now public 21-02-2025
  • Implementation of IHttpClientFactory to better dependency manage of the "HttpClient" 18-02-2025
  • It was solved the way of configure globally (ConfigureRequest) in the program file 23-01-2025
  • Was solved the configuration issues to Http and Request services + RequestHelper + Logs implementation 13/12/2024
  • It was added a new HttpHelper 12/12/2024
  • It was removed the TRequest at the method GetAsync + Logs 06/12/2024
  • Solved issue on serialize() & Added insensitiveMapping with default true 12/11/2024
  • It was added a content type in a Request and changed the models location + Fixed response issue 05/11/2024
  • It's added "CastResultAsResultHelper" parameter at HttpOption model in HttpService 29/10/2024

Created by Mario Soto Moreno

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  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. 
.NET Core netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.1 is compatible. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
1.5.7 144 10/31/2025
1.5.6 114 10/24/2025
1.5.5 168 10/23/2025
1.5.4 163 10/23/2025
1.5.2 164 10/22/2025
1.5.1 158 10/21/2025
1.5.0 158 10/21/2025
1.4.4 173 10/15/2025
1.4.3 190 10/9/2025
1.4.2 252 8/27/2025
1.4.1 160 7/17/2025
1.4.0 383 5/21/2025
1.3.3 258 4/16/2025
1.3.2 232 4/14/2025
1.3.1 222 4/14/2025
1.3.0 240 3/5/2025
1.2.8 149 2/21/2025
1.2.7 288 1/23/2025
1.2.6 183 12/13/2024
1.2.5 136 12/12/2024
1.2.4 276 12/6/2024
1.2.3 157 12/6/2024
1.2.2 158 12/6/2024
1.2.1 146 12/6/2024
1.2.0 175 12/6/2024
1.1.4 250 11/13/2024
1.1.3 164 11/12/2024
1.1.2 153 11/12/2024
1.1.1 144 11/5/2024
1.1.0 145 11/5/2024
1.0.3 139 11/4/2024
1.0.2 160 10/29/2024
1.0.1 181 10/29/2024
1.0.0 194 10/27/2024

- Removed FactoryTokenProvider as a singleton `31-10-2025`
- Implemented the IHttpFactory as a stateless, passing as parameter the clientName `24-10-2025`
- The response from all methods has changed from ResultHelper<T> to HttpResponse<T> to keep compatibility `23-10-2025`
- Now instead of clienName the key will be taking as a clientName `22-10-2025`
- Read multiple http clients from the appsettings.json `22-10-2025`
- "HttpFactoryOptions" configuration binded correctly `22-10-2025`
- It was solved "Unable to resolve service for type 'EssentialLayers.Request.Services.Factory.IFactoryTokenProvider" issue `21-10-2025`
- New provider based in IHttpClientFactory implementation to send requests `21-10-2025`
- Updating of dependencies to the last version `14-10-2025`
- In the model HttpOption, must be add an extra property to send the headers since ConfigureRequest `09/10/2025`
- Updating of nuget packages EssentialLayers and Microsoft.Extensions.Http `27/08/2025`
- Remove repeated headers `17-07-2025`
- Now all methods of RequestService & RequestHelper allows nullable results; It was fixed issue in uribase `21-05-2025`
- New Delete method in HttpService only with url `16-04-2025`
- Reverted dependency type from Scopped to Singleton; Beacuse always allows the overriding of base uri `14-04-2025`
- Now, the status "Created" is considered to be a successful response and "Unauthorized" to notify by message "Unauthorized" `14/04/2025`
- Reverted dependency type from Singleton to Scoped to allow multiple instances of the same service `05-03-2025`
- The HttpService and RequestService classes are now public `21-02-2025`
- Implementation of IHttpClientFactory to better dependency manage of the "HttpClient" `18-02-2025`
- It was solved the way of configure globally (ConfigureRequest) in the program file `23-01-2025`
- Was solved the configuration issues to Http and Request services + RequestHelper + Logs implementation `13/12/2024`
- It was added a new HttpHelper `12/12/2024`
- It was removed the TRequest at the method GetAsync + Logs `06/12/2024`
- Solved issue on serialize() & Added insensitiveMapping with default true `12/11/2024`
- It was added a content type in a Request and changed the models location + Fixed reponse issue `05/11/2024`
- It's added "CastResultAsResultHelper" parameter at HttpOption model in HttpService `29/10/2024`