Dosaic.Extensions.RestEase
1.1.8
See the version list below for details.
dotnet add package Dosaic.Extensions.RestEase --version 1.1.8
NuGet\Install-Package Dosaic.Extensions.RestEase -Version 1.1.8
<PackageReference Include="Dosaic.Extensions.RestEase" Version="1.1.8" />
<PackageVersion Include="Dosaic.Extensions.RestEase" Version="1.1.8" />
<PackageReference Include="Dosaic.Extensions.RestEase" />
paket add Dosaic.Extensions.RestEase --version 1.1.8
#r "nuget: Dosaic.Extensions.RestEase, 1.1.8"
#:package Dosaic.Extensions.RestEase@1.1.8
#addin nuget:?package=Dosaic.Extensions.RestEase&version=1.1.8
#tool nuget:?package=Dosaic.Extensions.RestEase&version=1.1.8
Dosaic.Extensions.RestEase
Dosaic.Extensions.RestEase is an extension library that simplifies HTTP API client creation using RestEase with built-in authentication and retry policies.
Installation
To install the nuget package follow these steps:
dotnet add package Dosaic.Extensions.RestEase
or add as package reference to your .csproj
<PackageReference Include="Dosaic.Extensions.RestEase" Version="" />
Usage
The extension provides a factory for creating typed API clients with minimal configuration.
Basic Client Creation
Create a simple API client interface:
using RestEase;
public interface IMyApi
{
[Get("users/{userId}")]
Task<User> GetUserAsync([Path] string userId);
[Post("users")]
Task<User> CreateUserAsync([Body] User user);
}
Then create a client instance:
using Dosaic.Extensions.RestEase;
IMyApi apiClient = RestClientFactory.Create<IMyApi>("https://api.example.com");
User user = await apiClient.GetUserAsync("123");
Authentication Support
Create a client with OAuth2 authentication:
using Dosaic.Extensions.RestEase;
using Dosaic.Extensions.RestEase.Authentication;
var authConfig = new AuthenticationConfig
{
Enabled = true,
BaseUrl = "https://auth.example.com",
TokenUrlPath = "oauth/token",
GrantType = GrantType.ClientCredentials,
ClientId = "myclientid",
ClientSecret = "myclientsecret"
};
IMyApi apiClient = RestClientFactory.Create<IMyApi>("https://api.example.com", authConfig);
Custom Retry Policy
You can specify a custom Polly retry policy:
using Dosaic.Extensions.RestEase;
using Polly;
using System.Net.Http;
var retryPolicy = Policy
.HandleResult<HttpResponseMessage>(r => !r.IsSuccessStatusCode)
.WaitAndRetryAsync(3, retry => TimeSpan.FromSeconds(Math.Pow(2, retry)));
IMyApi apiClient = RestClientFactory.Create<IMyApi>("https://api.example.com", retryPolicy);
Advanced Configuration
For complete customization, use all parameters:
using Dosaic.Extensions.RestEase;
using Dosaic.Extensions.RestEase.Authentication;
using Newtonsoft.Json;
using Polly;
var authConfig = new AuthenticationConfig
{
Enabled = true,
BaseUrl = "https://auth.example.com",
TokenUrlPath = "oauth/token",
GrantType = GrantType.Password,
Username = "myusername",
Password = "mypassword"
};
var retryPolicy = Policy
.HandleResult<HttpResponseMessage>(r => (int)r.StatusCode >= 500)
.RetryAsync(3);
var jsonSettings = new JsonSerializerSettings
{
NullValueHandling = NullValueHandling.Ignore
};
IMyApi apiClient = RestClientFactory.Create<IMyApi>(
"https://api.example.com",
authConfig,
retryPolicy,
jsonSettings
);
Authentication Types
The extension supports these OAuth2 grant types:
- Password - username and password authentication
- ClientCredentials - client ID and secret authentication
- Code - authorization code flow
// Password grant
var passwordAuth = new AuthenticationConfig
{
Enabled = true,
GrantType = GrantType.Password,
Username = "user",
Password = "pass"
};
// Client credentials
var clientAuth = new AuthenticationConfig
{
Enabled = true,
GrantType = GrantType.ClientCredentials,
ClientId = "client123",
ClientSecret = "secret456"
};
Default Behavior
By default, the extension uses:
- JSON serialization with string enum conversion
- A retry policy that retries 2 times for HTTP 5xx errors
- Automatic token refresh for authenticated requests
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. |
-
net9.0
- Microsoft.Extensions.Http.Polly (>= 9.0.6)
- RestEase (>= 1.6.4)
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.1.11 | 100 | 7/18/2025 |
1.1.10 | 88 | 7/18/2025 |
1.1.9 | 151 | 7/8/2025 |
1.1.8 | 147 | 7/7/2025 |
1.1.7 | 240 | 6/13/2025 |
1.1.6 | 151 | 6/5/2025 |
1.1.5 | 151 | 6/4/2025 |
1.1.4 | 136 | 6/4/2025 |
1.1.3 | 143 | 5/23/2025 |
1.1.2 | 163 | 5/8/2025 |
1.1.1 | 160 | 5/6/2025 |
1.1.0 | 124 | 5/2/2025 |
1.0.37 | 189 | 4/7/2025 |
1.0.36 | 493 | 3/25/2025 |
1.0.35 | 227 | 3/4/2025 |
1.0.34 | 222 | 3/4/2025 |
1.0.32 | 155 | 3/3/2025 |
1.0.30 | 128 | 1/30/2025 |
1.0.27 | 119 | 1/29/2025 |
1.0.26 | 104 | 1/29/2025 |
1.0.25 | 118 | 1/29/2025 |
1.0.18 | 112 | 1/23/2025 |
1.0.17 | 95 | 1/23/2025 |