Class HttpClientJsonExtensions
Helper methods for IHttpClient
Inherited Members
Namespace: Unity.Cloud.Common
Syntax
public static class HttpClientJsonExtensions
Methods
DeleteJsonAsync(IHttpClient, String, Object, CancellationToken)
Asynchronously performs a Delete-request, using Json to serialize payload/>
Declaration
public static Task<HttpResponseMessage> DeleteJsonAsync(this IHttpClient httpClient, string requestUri, object payload, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IHttpClient | httpClient | The HTTP client. |
String | requestUri | The Uri the request is sent to |
Object | payload | Optional Object that will be used as content of the request message |
CancellationToken | cancellationToken | Optional cancellation token that will try to cancel the operation. |
Returns
Type | Description |
---|---|
Task<HttpResponseMessage> | A task that will hold the HttpResponseMessage once the request is completed |
DeleteJsonAsync<TModel>(IHttpClient, String, Object, CancellationToken)
Asynchronously performs a Delete-request, using Json to serialize payload and deserialize response to a TModel
Declaration
public static async Task<TModel> DeleteJsonAsync<TModel>(this IHttpClient httpClient, string requestUri, object payload = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IHttpClient | httpClient | The HTTP client. |
String | requestUri | The Uri the request is sent to |
Object | payload | Optional Object that will be used as content of the request message |
CancellationToken | cancellationToken | Optional cancellation token that will try to cancel the operation. |
Returns
Type | Description |
---|---|
Task<TModel> | A task that will hold the |
Type Parameters
Name | Description |
---|---|
TModel | The type the response is deserialized to |
GetJsonAsync<TModel>(IHttpClient, String, CancellationToken)
Asynchronously performs a Get-request using Json to deserialize response to a TModel
Declaration
public static async Task<TModel> GetJsonAsync<TModel>(this IHttpClient httpClient, string requestUri, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IHttpClient | httpClient | The HTTP client. |
String | requestUri | The Uri the request is sent to |
CancellationToken | cancellationToken | Optional cancellation token that will try to cancel the operation. |
Returns
Type | Description |
---|---|
Task<TModel> | A task that will hold the |
Type Parameters
Name | Description |
---|---|
TModel | The type the response is deserialized to |
PostJsonAsync<TModel>(IHttpClient, String, Object, CancellationToken)
Asynchronously performs a Post-request, using Json to serialize payload and deserialize response to a TModel
Declaration
public static async Task<TModel> PostJsonAsync<TModel>(this IHttpClient httpClient, string requestUri, object payload = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IHttpClient | httpClient | The HTTP client. |
String | requestUri | The Uri the request is sent to |
Object | payload | Optional Object that will be used as content of the request message |
CancellationToken | cancellationToken | Optional cancellation token that will try to cancel the operation. |
Returns
Type | Description |
---|---|
Task<TModel> | A task that will hold the |
Type Parameters
Name | Description |
---|---|
TModel | The type the response is deserialized to |
PutJsonAsync<TModel>(IHttpClient, String, Object, CancellationToken)
Asynchronously performs a Put-request, using Json to serialize payload and deserialize response to a TModel
Declaration
public static async Task<TModel> PutJsonAsync<TModel>(this IHttpClient httpClient, string requestUri, object payload = null, CancellationToken cancellationToken = default(CancellationToken))
Parameters
Type | Name | Description |
---|---|---|
IHttpClient | httpClient | The HTTP client. |
String | requestUri | The Uri the request is sent to |
Object | payload | Optional Object that will be used as content of the request message |
CancellationToken | cancellationToken | Optional cancellation token that will try to cancel the operation. |
Returns
Type | Description |
---|---|
Task<TModel> | A task that will hold the |
Type Parameters
Name | Description |
---|---|
TModel | The type the response is deserialized to |