Pipopolam.Net.Http
0.3.7
Prefix Reserved
.NET Core 3.0
This package targets .NET Core 3.0. The package is compatible with this framework or higher.
.NET Standard 2.1
This package targets .NET Standard 2.1. The package is compatible with this framework or higher.
dotnet add package Pipopolam.Net.Http --version 0.3.7
NuGet\Install-Package Pipopolam.Net.Http -Version 0.3.7
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="Pipopolam.Net.Http" Version="0.3.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Pipopolam.Net.Http" Version="0.3.7" />
<PackageReference Include="Pipopolam.Net.Http" />
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 Pipopolam.Net.Http --version 0.3.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Pipopolam.Net.Http, 0.3.7"
#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 Pipopolam.Net.Http@0.3.7
#: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=Pipopolam.Net.Http&version=0.3.7
#tool nuget:?package=Pipopolam.Net.Http&version=0.3.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Pipopolam.Net Http Helper Library
Main goal of this library is to simplify client code HTTP-based APIs requests (e.g. REST, etc.)
Example
First of all we need to create subclass for WebService
and configure it.
public class RemoteError
{
public int Code { get; set; }
public string Message { get; set; }
}
// In case of server error (not 200(OK) response)
// try to parse server response into RemoteError object
public class MyService : WebService<RemoteError>
{
// All requests uses "example.com" host
public override string BaseHost => "example.com";
// All requests starts with "https://example.com/service
protected override void GenericServicePath(RequestBuilder builder) => builder.AddSegment("service");
}
Note that for .netcore and .net platforms
System.Text.Json
is used for serialization by default. For other platformsDataContractJsonSerializer
will be used.
Now we have class MyService
and can use it.
public class MyObject
{
public string SomeString { get; set; }
}
// Get service implementation, for example:
// MyService _service = Container.Resolve<MyService>();
// Usage
public async Task RequestObject()
{
try
{
// Make GET-request to https://example.com/service/object
MyObject obj = await _service.CreateRequest().AddSegment("object").Get<MyObject>();
Console.WriteLine($"Got: {obj.SomeString}!");
}
catch (WebServiceRemoteException<RemoteError> ex)
{
Console.WriteLine($"Something went wrong!\n{ex.Response.Message}");
}
}
public async Task PostObject()
{
try
{
// Make POST-request to https://example.com/service/object/set
// and set new object as request body
await _service.CreateRequest()
.AddSegment("object")
.AddSegment("set")
.Body(new MyObject { SomeString = "Hello, world!" })
.Post();
}
catch (WebServiceRemoteException<RemoteError> ex)
{
Console.WriteLine($"Something went wrong!\n{ex.Response.Message}");
}
}
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. 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. net9.0 was computed. 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. |
.NET Core | netcoreapp3.0 is compatible. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETCoreApp 3.0
- No dependencies.
-
.NETStandard 2.1
- No dependencies.
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 |
---|---|---|
0.3.7 | 166 | 1/26/2024 |
0.3.6 | 115 | 1/26/2024 |
0.3.2-alpha | 103 | 1/21/2024 |
0.3.1-alpha | 96 | 1/20/2024 |
0.2.8 | 127 | 1/19/2024 |
0.2.5 | 127 | 1/18/2024 |
0.2.4-alpha-g1870997718 | 97 | 1/18/2024 |
0.1.0 | 135 | 1/15/2024 |
The release notes are available at https://github.com/Quickern/Pipopolam.Net.Http/releases.