Opx.HttpClient 1.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Opx.HttpClient --version 1.0.2                
NuGet\Install-Package Opx.HttpClient -Version 1.0.2                
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="Opx.HttpClient" Version="1.0.2" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Opx.HttpClient --version 1.0.2                
#r "nuget: Opx.HttpClient, 1.0.2"                
#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 Opx.HttpClient as a Cake Addin
#addin nuget:?package=Opx.HttpClient&version=1.0.2

// Install Opx.HttpClient as a Cake Tool
#tool nuget:?package=Opx.HttpClient&version=1.0.2                

Opx.HttpClient

HTTP Client tools, simplify HttpClient.

NuGet version (Opx.HttpClient)

Usage

Basic

var api = new ApiRequest("https://localhost");

// https://localhost/customers
var customers = await api.RequestJsonAsync<List<Customer>>(HttpMethod.Post, "customers");

Parameter From Query

// https://localhost/customers?Active=true&Sort=name
var customers = await api.RequestJsonAsync<List<Customer>>(HttpMethod.Get, "customers", new ApiRequestParameter()
{
    FromQuery = new
    {
        Active = true,
        Sort = "name"
    }
);

Parameter From Route

// https://localhost/customers/1
var customer = await api.RequestJsonAsync<Customer>(HttpMethod.Get, "customers/{Id}", new ApiRequestParameter()
{
    FromRoute = new
    {
        Id = 1
    }
);

Parameter From Body

// https://localhost/customers/save
var success = await api.RequestJsonAsync<bool>(HttpMethod.Post, "customers/save", new ApiRequestParameter()
{
    FromBody = new
    {
        Id = 1,
        FirstName = "John",
        LastName = "Doe"
    }
);

You can mix those parameters together.

HTTP Request Version

Default RequestVersion is HTTP/2

var doc = new DocRequest("https://tools.keycdn.com/http2-test", HttpRequestVersion.Http20);
var res = doc.RequestString(HttpMethod.Get);

For HTTP/3 you must set httpVersionPolicy to HttpVersionPolicy.RequestVersionExact

var doc = new DocRequest("https://cloudflare-quic.com", HttpRequestVersion.Http30, HttpVersionPolicy.RequestVersionExact);
var res = doc.RequestString(HttpMethod.Get);
Product Compatible and additional computed target framework versions.
.NET 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net8.0

    • No dependencies.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Opx.HttpClient:

Package Downloads
Opx.WebApi

Package Description

Opx.LApis

Package Description

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.3 65 11/19/2024
1.0.2 108 10/4/2024
1.0.1 85 10/3/2024
1.0.0 88 10/3/2024