OutWit.Common.Rest 1.0.0

dotnet add package OutWit.Common.Rest --version 1.0.0                
NuGet\Install-Package OutWit.Common.Rest -Version 1.0.0                
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="OutWit.Common.Rest" Version="1.0.0" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OutWit.Common.Rest --version 1.0.0                
#r "nuget: OutWit.Common.Rest, 1.0.0"                
#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.
// Install OutWit.Common.Rest as a Cake Addin
#addin nuget:?package=OutWit.Common.Rest&version=1.0.0

// Install OutWit.Common.Rest as a Cake Tool
#tool nuget:?package=OutWit.Common.Rest&version=1.0.0                

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
Product 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. 
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.0.0 91 1/2/2025