Solid.Http.Json Usage - SOLIDSoftworks/Solid.Http GitHub Wiki

Adding json content to the request

Adding xml serialized content to the request can be done as follows

var client = context.RequestServices.GetRequiredService<ISolidHttpClientFactory>().CreateWithBaseAddress("http://SomeBaseUri");
var obj = new ObjectToSerialize();
var response = await client
    .PostAsync("some/path/that/accepts/xml/post", cancellationToken)
    .WithJsonContent(obj)

Deserializing json response content

Getting serialized xml to objects can be done as follows

var client = context.RequestServices.GetRequiredService<ISolidHttpClientFactory>().CreateWithBaseAddress("http://SomeBaseUri");
var serializedObject = await client
    .GetAsync("some/path/that/returns/xml/that/can/be/serialized/to/ObjectToSerialize", cancellationToken)
    .As<ObjectToSerialize>();
var client = context.RequestServices.GetRequiredService<ISolidHttpClientFactory>().CreateWithBaseAddress("http://SomeBaseUri");
var serializedObject = await client
    .GetAsync("some/path/that/returns/xml/that/can/be/serialized/to/array/of/ObjectToSerialize", cancellationToken)
    .AsMany<ObjectToSerialize>();