OutWit.Common.Rest
1.2.1
dotnet add package OutWit.Common.Rest --version 1.2.1
NuGet\Install-Package OutWit.Common.Rest -Version 1.2.1
<PackageReference Include="OutWit.Common.Rest" Version="1.2.1" />
<PackageVersion Include="OutWit.Common.Rest" Version="1.2.1" />
<PackageReference Include="OutWit.Common.Rest" />
paket add OutWit.Common.Rest --version 1.2.1
#r "nuget: OutWit.Common.Rest, 1.2.1"
#:package OutWit.Common.Rest@1.2.1
#addin nuget:?package=OutWit.Common.Rest&version=1.2.1
#tool nuget:?package=OutWit.Common.Rest&version=1.2.1
OutWit.Common.Rest
Overview
OutWit.Common.Rest is a robust library designed to simplify and streamline HTTP client interactions in .NET applications. By leveraging a modular and extensible architecture, it offers powerful abstractions for building and executing RESTful requests, handling responses, and managing query parameters with ease.
Features
1. Query Builder
The QueryBuilder class provides a fluent API for constructing URL query strings dynamically. It supports multiple parameter types, including primitives, enumerations, and collections.
Example Usage
var queryBuilder = new QueryBuilder()
.AddParameter("name", "John Doe")
.AddParameter("age", 30)
.AddParameter("tags", new[] { "developer", "blogger" });
string query = await queryBuilder.AsStringAsync();
Console.WriteLine(query); // Output: name=John%20Doe&age=30&tags=developer,blogger
2. REST Client
The RestClient class provides an abstraction for HTTP operations, including GET, POST, and SEND requests. It simplifies common tasks like deserialization and content creation while allowing advanced configuration with fluent methods.
Example Usage
var client = RestClientBuilder.Create()
.WithBearer("your-token")
.WithHeader("Custom-Header", "HeaderValue");
var result = await client.GetAsync<MyResponseType>("https://api.example.com/resource");
3. Exception Handling
The RestClientException class encapsulates HTTP status codes and response content, making error handling intuitive and detailed.
Example
try
{
var result = await client.GetAsync<MyResponseType>("https://api.example.com/invalid-resource");
}
catch (RestClientException ex)
{
Console.WriteLine($"Error: {ex.StatusCode}, Content: {ex.Content}");
}
4. Serialization and Deserialization
Integrated with Newtonsoft.Json, the library supports efficient serialization and deserialization of request and response content.
Deserialize Example
var response = await httpResponseMessage.DeserializeAsync<MyResponseType>();
5. Builder Utilities
The library includes utilities for building requests with advanced features like:
- Custom authorization headers
- Content serialization
- Dynamic query parameter handling
Installation
Install the package via NuGet:
Install-Package OutWit.Common.Rest
License
Licensed under the Apache License, Version 2.0. See LICENSE.
Attribution (optional)
If you use OutWit.Common.Rest in a product, a mention is appreciated (but not required), for example: "Powered by OutWit.Common.Rest (https://ratner.io/)".
Trademark / Project name
"OutWit" and the OutWit logo are used to identify the official project by Dmitry Ratner.
You may:
- refer to the project name in a factual way (e.g., "built with OutWit.Common.Rest");
- use the name to indicate compatibility (e.g., "OutWit.Common.Rest-compatible").
You may not:
- use "OutWit.Common.Rest" as the name of a fork or a derived product in a way that implies it is the official project;
- use the OutWit.Common.Rest logo to promote forks or derived products without permission.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. 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 is compatible. 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 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 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 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
- OutWit.Common (>= 1.3.2)
-
net6.0
- OutWit.Common (>= 1.3.2)
-
net7.0
- OutWit.Common (>= 1.3.2)
-
net8.0
- OutWit.Common (>= 1.3.2)
-
net9.0
- OutWit.Common (>= 1.3.2)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on OutWit.Common.Rest:
| Package | Downloads |
|---|---|
|
OutWit.Communication.Client.Rest
REST transport client for WitRPC, allowing communication with a WitRPC server over HTTP (RESTful) calls - ideal for integrating with web services or non-.NET clients. |
|
|
OutWit.Common.Logging.NewRelic
NewRelic NerdGraph log query backend for OutWit.Common.Logging.Query. Implements ILogQueryProvider over NRQL (search, statistics, distinct values, scroll-to-timestamp) and adds NewRelic-specific billing data via INewRelicProvider. |
|
|
OutWit.Common.NewRelic
New Relic integration utilities for .NET applications |
GitHub repositories
This package is not used by any popular GitHub repositories.