EasyHttpsClient 1.2.0
See the version list below for details.
dotnet add package EasyHttpsClient --version 1.2.0
NuGet\Install-Package EasyHttpsClient -Version 1.2.0
<PackageReference Include="EasyHttpsClient" Version="1.2.0" />
<PackageVersion Include="EasyHttpsClient" Version="1.2.0" />
<PackageReference Include="EasyHttpsClient" />
paket add EasyHttpsClient --version 1.2.0
#r "nuget: EasyHttpsClient, 1.2.0"
#:package EasyHttpsClient@1.2.0
#addin nuget:?package=EasyHttpsClient&version=1.2.0
#tool nuget:?package=EasyHttpsClient&version=1.2.0
EasyHttpsClient
v1.2.0
EasyHttpsClient is a simple and easy-to-use HTTP client library for .NET. It provides a fluent API for sending HTTP(s) POST and GET requests and retrieving responses.
Usage
GET Request To send a GET request, use the GETasync method:
var client = new HttpsClient();
client.SetUrl("https://example.com/api/data");
await client.GETasync();
var response = await client.ReadResultAsStringAsync();
Console.WriteLine(response);
To send a POST request, use the POSTasync method:
var client = new HttpsClient();
client.SetUrl("https://example.com/api/PostHereFormUrlEncodedData/");
client.SetBodyPostData(new List<KeyValuePair<string, string>>
{
new KeyValuePair<string, string>("key1", "value1"),
new KeyValuePair<string, string>("key2", "value2")
});
await client.POSTasync();
var response = await client.ReadResultAsStringAsync();
Console.WriteLine(response);
To send a POST request with a JSON body, use the SetBodyRequestData method
var client = new HttpsClient();
client.SetUrl("https://example.com/api/PostHereInPostBody/");
//example object, it can be any object that can be serialized
var data = new { key1 = "value1", key2 = "value2", ... };
client.SetBodyRequestData(data);
// or use client.SetBodyRequestJson(...);
await client.POSTasync();
var response = await client.ReadResultAsStringAsync();
Console.WriteLine(response);
Setting Timeout and Encoding You can set the timeout and encoding for the HTTP client using the SetTimeout and SetEncoding methods:
var client = new HttpsClient();
client.SetTimeout(10); // set timeout to 10 seconds
client.SetEncoding(Encoding.UTF8); // set encoding to UTF-8
Adding Headers You can add headers to the HTTP request using the AddToRequestHeaders method:
var client = new HttpsClient();
client.AddToRequestHeaders("Authorization", "Bearer token ...");
Supports Fluent syntax
HttpsClient client = new EasyHttpsClient.HttpsClient();
await client
.SetUrl("https://example.com/etc/GetIt.html")
.SetTimeout(15)
.SetEncoding(Encoding.UTF8)
.GETasync();
byte[] bytearray = await client.ReadResultAsByteArrayAsync();
string response = await client.ReadResultAsStringAsync();
Disposing Don't forget to dispose the HTTP client when you're done with it to free up memory:
var client = new HttpsClient();
// ...
client.Dispose();
| 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 | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- System.Net.Http (>= 4.2.0)
- System.Text.Json (>= 9.0.9)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.