This repository was archived by the owner on Apr 10, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Solid.Http.Json Usage
Gísli Konráð Björnsson edited this page Mar 17, 2018
·
1 revision
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)
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>();