Dosaic.Extensions.RestEase
1.2.3
dotnet add package Dosaic.Extensions.RestEase --version 1.2.3
NuGet\Install-Package Dosaic.Extensions.RestEase -Version 1.2.3
<PackageReference Include="Dosaic.Extensions.RestEase" Version="1.2.3" />
<PackageVersion Include="Dosaic.Extensions.RestEase" Version="1.2.3" />
<PackageReference Include="Dosaic.Extensions.RestEase" />
paket add Dosaic.Extensions.RestEase --version 1.2.3
#r "nuget: Dosaic.Extensions.RestEase, 1.2.3"
#:package Dosaic.Extensions.RestEase@1.2.3
#addin nuget:?package=Dosaic.Extensions.RestEase&version=1.2.3
#tool nuget:?package=Dosaic.Extensions.RestEase&version=1.2.3
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 | net10.0 is compatible. 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. |
-
net10.0
- Microsoft.Extensions.Http.Polly (>= 10.0.2)
- 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.2.3 | 89 | 1/27/2026 |
| 1.2.2 | 290 | 12/16/2025 |
| 1.2.1 | 273 | 12/16/2025 |
| 1.2.0 | 428 | 12/11/2025 |
| 1.1.21 | 453 | 12/10/2025 |
| 1.1.20 | 413 | 11/18/2025 |
| 1.1.19 | 303 | 11/11/2025 |
| 1.1.18 | 206 | 10/14/2025 |
| 1.1.17 | 198 | 10/1/2025 |
| 1.1.16 | 200 | 9/25/2025 |
| 1.1.15 | 197 | 9/24/2025 |
| 1.1.14 | 196 | 9/24/2025 |
| 1.1.13 | 210 | 9/24/2025 |
| 1.1.12 | 325 | 9/16/2025 |
| 1.1.11 | 171 | 7/18/2025 |
| 1.1.10 | 158 | 7/18/2025 |
| 1.1.9 | 203 | 7/8/2025 |
| 1.1.8 | 202 | 7/7/2025 |
| 1.1.7 | 306 | 6/13/2025 |
| 1.1.6 | 204 | 6/5/2025 |
| 1.1.5 | 203 | 6/4/2025 |
| 1.1.4 | 186 | 6/4/2025 |
| 1.1.3 | 199 | 5/23/2025 |
| 1.1.2 | 215 | 5/8/2025 |
| 1.1.1 | 205 | 5/6/2025 |
| 1.1.0 | 174 | 5/2/2025 |
| 1.0.37 | 230 | 4/7/2025 |
| 1.0.36 | 540 | 3/25/2025 |
| 1.0.35 | 272 | 3/4/2025 |
| 1.0.34 | 271 | 3/4/2025 |
| 1.0.32 | 222 | 3/3/2025 |
| 1.0.30 | 182 | 1/30/2025 |
| 1.0.27 | 167 | 1/29/2025 |
| 1.0.26 | 150 | 1/29/2025 |
| 1.0.25 | 169 | 1/29/2025 |
| 1.0.18 | 160 | 1/23/2025 |
| 1.0.17 | 146 | 1/23/2025 |