OutWit.Common.Rest 1.1.1

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

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.  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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (1)

Showing the top 1 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.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.1.1 108 6/28/2025
1.1.0 104 6/6/2025
1.0.0 125 1/2/2025