YamlHttpClient 1.0.5

dotnet add package YamlHttpClient --version 1.0.5
NuGet\Install-Package YamlHttpClient -Version 1.0.5
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="YamlHttpClient" Version="1.0.5" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add YamlHttpClient --version 1.0.5
#r "nuget: YamlHttpClient, 1.0.5"
#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 YamlHttpClient as a Cake Addin
#addin nuget:?package=YamlHttpClient&version=1.0.5

// Install YamlHttpClient as a Cake Tool
#tool nuget:?package=YamlHttpClient&version=1.0.5

YamlHttpClient

Yaml config based .net HttpClient

Download from NuGet https://www.nuget.org/packages/YamlHttpClient/

How to use

// Sample object
var anyInputObject = new
{
	table = new[] { "v1", "v2" },
	date = new DateTime(2000, 1, 1),
	obj = new[] { new { test = 1 }, new { test = 2 } },
	val1 = new Dictionary<string, object>() { { "testkey", "testval" } },
	place = "urlPartDemo",
	System = new { CodeNT = "internalCode" }
};

// Source config
var file = @"myYamlConfig.yml";

// Core builder, load settings from Yaml source
YamlHttpClientFactory httpClient = new YamlHttpClientFactory(new YamlHttpClientConfigBuilder()
								 .LoadFromFile(file, "myHttpCall"));

// Here the magic - Build Http message - Dynamically
// from config with your object as data source, see yaml config below
var request = httpClient.BuildRequestMessage(anyInputObject);

// Inspect content if needed
var readContent = await request.Content.ReadAsStringAsync();

// Send it
var response = await httpClient.SendAsync(request);

// Do something with response
var returnData = await response.Content.ReadAsStringAsync();

// Check some stuff from config
await httpClient.CheckResponseAsync(response);

Yaml config sample

http_client:
  # Named config key
  myHttpCall:
      method: POST
      url: https://ptsv2.com/t/{{place}}/post
      # Ntlm auto negociation
      use_default_credentials: true
      # Any specific required headers
      headers:
          CodeNT: '{{System.CodeNT}}'
          Accept: 'application/json'
      # Example Json content to send, with token template value replacement by Handlebars.net
      content:
          json_content: |
            {
              "someVal": "{{val1}}", 
              "flattenObj": {{{Json . ">flatten;_;_{0}" ">forcestring"}}}
              "obj": {{{Json .}}}
            }
      # Quality assurance if supported by implementation to self check response raw body
      check_response:
        throw_exception_if_body_contains_any:
            - error
        throw_exception_if_body_not_contains_all:
            - dump

Where VAR is from passed data.

{{{Json VAR}}} # Simple object to json serialization
{{{Json VAR ">flatten;.;[{0}]"}}} # Flatten object to one level dictionary. Child naming childName[0].prop
{{{Json VAR ">flatten;_;_{0}" ">forcestring"}}} # Flatten object to one level dictionary. Child naming childName_0_prop. Force String values.

Features support checklist

  • ✅ Support all http methods, POST, GET, DELETE...
  • ✅ Send any header
  • ✅ Send JSON, string, form data, binary files
  • ✅ Basic Http Authentication
  • ✅ NTLM (with use default credentials, app pool auto authentication)
  • ✅ Check response content and throw exception if response is not expected
  • ⬜ NTLM with user/password
  • ⬜ Client certificate Authentication
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  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 is compatible.  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. 
.NET Core netcoreapp3.1 is compatible. 
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
1.0.5 160 9/15/2023
1.0.4 134 9/15/2023
1.0.3 108 9/15/2023
1.0.2 210 3/15/2023
1.0.1 646 3/29/2022
1.0.0 460 1/30/2022
1.0.0-rc7 190 11/9/2021
1.0.0-rc6 213 11/9/2021
1.0.0-rc5 191 11/9/2021
1.0.0-rc4 173 11/8/2021
1.0.0-rc3 215 11/8/2021
1.0.0-rc2 224 11/5/2021
1.0.0-rc1 195 11/5/2021
1.0.0-beta4 206 9/3/2021
1.0.0-beta3 189 8/29/2021
1.0.0-beta2 194 8/28/2021
1.0.0-beta1 188 8/28/2021
1.0.0-alpha8 188 8/26/2021
1.0.0-alpha7 180 8/26/2021
1.0.0-alpha6 181 8/26/2021
1.0.0-alpha5 200 8/25/2021
1.0.0-alpha4 165 8/25/2021
1.0.0-alpha3 235 8/25/2021
1.0.0-alpha2 244 8/25/2021
1.0.0-alpha1 246 8/25/2021