RequesterNetLib 1.0.0

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

// Install RequesterNetLib as a Cake Tool
#tool nuget:?package=RequesterNetLib&version=1.0.0

RequesterNet

RequesterNet Logo

RequesterNet is a simple and fast REST and HTTP API Client for .NET Core.

Getting started

First, install the package by executing the following command:

PM> Install-Package RequesterNetLib

Then, in your ConfigureServices method use:

public void ConfigureServices(IServiceCollection services)
{
    services.AddRequesterNet();
}

Or with options:

public void ConfigureServices(IServiceCollection services)
{
    services.AddRequesterNet(opt =>
    {
        opt.UrlBase = "https://example.com",
        opt.DefaultHeaders = new Dictionary<string, string>
        {
            { "Authorization", "Bearer myBearerToken" }
        }
    });
}
Option Description Type Default
UrlBase Set the base url for all calls when using RequesterNet. string null
DefaultHeaders Set the default headers for all calls when using RequesterNet. Dictionary<string, string> empty

Usage

Use the interface IRequesterNet in constructor:

private readonly IRequesterNet _requester;

public MyClass(IRequesterNet requester)
{
   _requester = requester;
}

Get

A simple Get request (if a base url is setted only "/endpoint" is required):

public void Get()
{
   var response = await _requester.GetAsync("https://example.com/endpoint");
}

Get (parameters and headers)

RequesterNet helps with binding parameters and headers in any request. A simple Get request with custom parameters and headers:

public void Get()
{
   var parameters = new Dictionary<string, string>
   {
      { "search", "foo" },
      { "page", "1" }
   };
   var headers = new Dictionary<string, string>
   {
      { "Authorization", "Bearer myBearerToken" },
      { "x-api-key", "myApiKey" }
   };
   var response = await _requester.GetAsync("https://example.com/endpoint", parameters, headers);
   //Final url results in: https://example.com/endpoint?search=foo&page=1
}

Post

Post method follows the same parameters like Get but with a optional body object, example:

public void Post()
{
   var parameters = new Dictionary<string, string>
   {
      { "search", "foo" },
      { "page", "1" }
   };
   var headers = new Dictionary<string, string>
   {
      { "Authorization", "Bearer myBearerToken" },
      { "x-api-key", "myApiKey" }
   };
   var body = new
   {
      Username = "myUsername",
      Password = "myPassword"
   };
   var response = await _requester.PostAsync("https://example.com/endpoint", parameters, headers, body);
}

Other methods

RequesterNet has the common http methods, being:

Method Url Parameters Headers Body
GetAsync :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:
PostAsync :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:
PutAsync :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:
PatchAsync :heavy_check_mark: :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:
DeleteAsync :heavy_check_mark: :heavy_check_mark: :heavy_check_mark:
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 was computed.  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 was computed.  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 was computed.  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.

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
3.1.19 380 9/24/2021
1.1.0 274 6/3/2021
1.0.0 304 5/31/2021