KolClient 1.0.7
dotnet add package KolClient --version 1.0.7
NuGet\Install-Package KolClient -Version 1.0.7
<PackageReference Include="KolClient" Version="1.0.7" />
<PackageVersion Include="KolClient" Version="1.0.7" />
<PackageReference Include="KolClient" />
paket add KolClient --version 1.0.7
#r "nuget: KolClient, 1.0.7"
#:package KolClient@1.0.7
#addin nuget:?package=KolClient&version=1.0.7
#tool nuget:?package=KolClient&version=1.0.7
Start by defining headers to use with the http client.
E.g. for consuming soap services
var specialHeaders = new HeaderInfo[]
{
new HeaderInfo
{
Header = Constants.ACCEPT,
Value = "*/*"
}
};
Define a base url in appsettings json
"BaseUrl": "http://127.0.0.1:1234/"
Inject the http client
builder.InjectHttpServiceFromBaseUrl(useUnsafe: true, specialHeaders: specialHeaders, configureAsJson: false);
useUnsafe means trust any ssl certificate
configureAsJson means accept header should be set to json. For soap set this to false
There are 3 ways of injecting http client
InjectHttpServiceFromBaseUrl
explained above
InjectHttpServiceFromSection
provide the appsettings json section name e.g. Urls:BaseUrl
InjectHttpService
Set everything manually
Explore the methods in KolHttpClient - GET, PUT, POST, DELETE, and methods for adding headers and all. There is also KolUtils, a static class which provides other helpful methods like base 64 encoding and decoding, Xml and JSON serialization and deserialization.
| Product | Versions 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 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. |
-
net6.0
- Microsoft.Extensions.Configuration.Abstractions (>= 6.0.0)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Injecting:
public static void InjectKolClient(this WebApplicationBuilder builder)
{
var specialHeaders = new HeaderInfo[]
{
new HeaderInfo
{
Header = Constants.ACCEPT,
Value = "*/*"
}
};
builder.InjectHttpServiceFromBaseUrl(useUnsafe: KolUtils.GetValueFromAppSettings<bool>(builder.Configuration, "UseUnsafe"),
specialHeaders: specialHeaders, configureAsJson: KolUtils.GetValueFromAppSettings<bool>(builder.Configuration, "ConfigureAsJson"));
}