Edit

Share via


HttpClientJsonExtensions.PostAsJsonAsync Method

Definition

Overloads

PostAsJsonAsync<TValue>(HttpClient, String, TValue, CancellationToken)

Sends a POST request to the specified Uri containing the value serialized as JSON in the request body.

PostAsJsonAsync<TValue>(HttpClient, Uri, TValue, CancellationToken)

Sends a POST request to the specified Uri containing the value serialized as JSON in the request body.

PostAsJsonAsync<TValue>(HttpClient, String, TValue, JsonSerializerOptions, CancellationToken)

Sends a POST request to the specified Uri containing the value serialized as JSON in the request body.

PostAsJsonAsync<TValue>(HttpClient, String, TValue, JsonTypeInfo<TValue>, CancellationToken)

Sends a POST request to the specified Uri containing the value serialized as JSON in the request body.

PostAsJsonAsync<TValue>(HttpClient, Uri, TValue, JsonSerializerOptions, CancellationToken)

Sends a POST request to the specified Uri containing the value serialized as JSON in the request body.

PostAsJsonAsync<TValue>(HttpClient, Uri, TValue, JsonTypeInfo<TValue>, CancellationToken)

Sends a POST request to the specified Uri containing the value serialized as JSON in the request body.

PostAsJsonAsync<TValue>(HttpClient, String, TValue, CancellationToken)

Source:
HttpClientJsonExtensions.Post.cs
Source:
HttpClientJsonExtensions.Post.cs
Source:
HttpClientJsonExtensions.Post.cs
Source:
HttpClientJsonExtensions.Post.cs
Source:
HttpClientJsonExtensions.Post.cs

Sends a POST request to the specified Uri containing the value serialized as JSON in the request body.

public:
generic <typename TValue>
[System::Runtime::CompilerServices::Extension]
 static System::Threading::Tasks::Task<System::Net::Http::HttpResponseMessage ^> ^ PostAsJsonAsync(System::Net::Http::HttpClient ^ client, System::String ^ requestUri, TValue value, System::Threading::CancellationToken cancellationToken);
public static System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> PostAsJsonAsync<TValue> (this System.Net.Http.HttpClient client, string? requestUri, TValue value, System.Threading.CancellationToken cancellationToken);
static member PostAsJsonAsync : System.Net.Http.HttpClient * string * 'Value * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
<Extension()>
Public Function PostAsJsonAsync(Of TValue) (client As HttpClient, requestUri As String, value As TValue, cancellationToken As CancellationToken) As Task(Of HttpResponseMessage)

Type Parameters

TValue

The type of the value to serialize.

Parameters

client
HttpClient

The client used to send the request.

requestUri
String

The Uri the request is sent to.

value
TValue

The value to serialize.

cancellationToken
CancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns

The task object representing the asynchronous operation.

Exceptions

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

This method uses JsonSerializerDefaults.Web options for serialization, whereas JsonSerializer serialization methods do not, by default.

Applies to

PostAsJsonAsync<TValue>(HttpClient, Uri, TValue, CancellationToken)

Source:
HttpClientJsonExtensions.Post.cs
Source:
HttpClientJsonExtensions.Post.cs
Source:
HttpClientJsonExtensions.Post.cs
Source:
HttpClientJsonExtensions.Post.cs
Source:
HttpClientJsonExtensions.Post.cs

Sends a POST request to the specified Uri containing the value serialized as JSON in the request body.

public:
generic <typename TValue>
[System::Runtime::CompilerServices::Extension]
 static System::Threading::Tasks::Task<System::Net::Http::HttpResponseMessage ^> ^ PostAsJsonAsync(System::Net::Http::HttpClient ^ client, Uri ^ requestUri, TValue value, System::Threading::CancellationToken cancellationToken);
public static System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> PostAsJsonAsync<TValue> (this System.Net.Http.HttpClient client, Uri? requestUri, TValue value, System.Threading.CancellationToken cancellationToken);
static member PostAsJsonAsync : System.Net.Http.HttpClient * Uri * 'Value * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
<Extension()>
Public Function PostAsJsonAsync(Of TValue) (client As HttpClient, requestUri As Uri, value As TValue, cancellationToken As CancellationToken) As Task(Of HttpResponseMessage)

Type Parameters

TValue

The type of the value to serialize.

Parameters

client
HttpClient

The client used to send the request.

requestUri
Uri

The Uri the request is sent to.

value
TValue

The value to serialize.

cancellationToken
CancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns

The task object representing the asynchronous operation.

Exceptions

The cancellation token was canceled. This exception is stored into the returned task.

Remarks

This method uses JsonSerializerDefaults.Web options for serialization, whereas JsonSerializer serialization methods do not, by default.

Applies to

PostAsJsonAsync<TValue>(HttpClient, String, TValue, JsonSerializerOptions, CancellationToken)

Source:
HttpClientJsonExtensions.Post.cs
Source:
HttpClientJsonExtensions.Post.cs
Source:
HttpClientJsonExtensions.Post.cs
Source:
HttpClientJsonExtensions.Post.cs
Source:
HttpClientJsonExtensions.Post.cs

Sends a POST request to the specified Uri containing the value serialized as JSON in the request body.

public static System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> PostAsJsonAsync<TValue> (this System.Net.Http.HttpClient client, string? requestUri, TValue value, System.Text.Json.JsonSerializerOptions? options = default, System.Threading.CancellationToken cancellationToken = default);
static member PostAsJsonAsync : System.Net.Http.HttpClient * string * 'Value * System.Text.Json.JsonSerializerOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
<Extension()>
Public Function PostAsJsonAsync(Of TValue) (client As HttpClient, requestUri As String, value As TValue, Optional options As JsonSerializerOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of HttpResponseMessage)

Type Parameters

TValue

The type of the value to serialize.

Parameters

client
HttpClient

The client used to send the request.

requestUri
String

The Uri the request is sent to.

value
TValue

The value to serialize.

options
JsonSerializerOptions

Options to control the behavior during serialization. The default options are those specified by Web.

cancellationToken
CancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns

The task object representing the asynchronous operation.

Exceptions

The cancellation token was canceled. This exception is stored into the returned task.

Applies to

PostAsJsonAsync<TValue>(HttpClient, String, TValue, JsonTypeInfo<TValue>, CancellationToken)

Source:
HttpClientJsonExtensions.Post.cs
Source:
HttpClientJsonExtensions.Post.cs
Source:
HttpClientJsonExtensions.Post.cs
Source:
HttpClientJsonExtensions.Post.cs
Source:
HttpClientJsonExtensions.Post.cs

Sends a POST request to the specified Uri containing the value serialized as JSON in the request body.

public static System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> PostAsJsonAsync<TValue> (this System.Net.Http.HttpClient client, string? requestUri, TValue value, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TValue> jsonTypeInfo, System.Threading.CancellationToken cancellationToken = default);
static member PostAsJsonAsync : System.Net.Http.HttpClient * string * 'Value * System.Text.Json.Serialization.Metadata.JsonTypeInfo<'Value> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
<Extension()>
Public Function PostAsJsonAsync(Of TValue) (client As HttpClient, requestUri As String, value As TValue, jsonTypeInfo As JsonTypeInfo(Of TValue), Optional cancellationToken As CancellationToken = Nothing) As Task(Of HttpResponseMessage)

Type Parameters

TValue

The type of the value to serialize.

Parameters

client
HttpClient

The client used to send the request.

requestUri
String

The Uri the request is sent to.

value
TValue

The value to serialize.

jsonTypeInfo
JsonTypeInfo<TValue>

The JsonTypeInfo used to control the serialization behavior.

cancellationToken
CancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns

The task object representing the asynchronous operation.

Exceptions

The cancellation token was canceled. This exception is stored into the returned task.

Applies to

PostAsJsonAsync<TValue>(HttpClient, Uri, TValue, JsonSerializerOptions, CancellationToken)

Source:
HttpClientJsonExtensions.Post.cs
Source:
HttpClientJsonExtensions.Post.cs
Source:
HttpClientJsonExtensions.Post.cs
Source:
HttpClientJsonExtensions.Post.cs
Source:
HttpClientJsonExtensions.Post.cs

Sends a POST request to the specified Uri containing the value serialized as JSON in the request body.

public static System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> PostAsJsonAsync<TValue> (this System.Net.Http.HttpClient client, Uri? requestUri, TValue value, System.Text.Json.JsonSerializerOptions? options = default, System.Threading.CancellationToken cancellationToken = default);
static member PostAsJsonAsync : System.Net.Http.HttpClient * Uri * 'Value * System.Text.Json.JsonSerializerOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
<Extension()>
Public Function PostAsJsonAsync(Of TValue) (client As HttpClient, requestUri As Uri, value As TValue, Optional options As JsonSerializerOptions = Nothing, Optional cancellationToken As CancellationToken = Nothing) As Task(Of HttpResponseMessage)

Type Parameters

TValue

The type of the value to serialize.

Parameters

client
HttpClient

The client used to send the request.

requestUri
Uri

The Uri the request is sent to.

value
TValue

The value to serialize.

options
JsonSerializerOptions

Options to control the behavior during serialization. The default options are those specified by Web.

cancellationToken
CancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns

The task object representing the asynchronous operation.

Exceptions

The cancellation token was canceled. This exception is stored into the returned task.

Applies to

PostAsJsonAsync<TValue>(HttpClient, Uri, TValue, JsonTypeInfo<TValue>, CancellationToken)

Source:
HttpClientJsonExtensions.Post.cs
Source:
HttpClientJsonExtensions.Post.cs
Source:
HttpClientJsonExtensions.Post.cs
Source:
HttpClientJsonExtensions.Post.cs
Source:
HttpClientJsonExtensions.Post.cs

Sends a POST request to the specified Uri containing the value serialized as JSON in the request body.

public static System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> PostAsJsonAsync<TValue> (this System.Net.Http.HttpClient client, Uri? requestUri, TValue value, System.Text.Json.Serialization.Metadata.JsonTypeInfo<TValue> jsonTypeInfo, System.Threading.CancellationToken cancellationToken = default);
static member PostAsJsonAsync : System.Net.Http.HttpClient * Uri * 'Value * System.Text.Json.Serialization.Metadata.JsonTypeInfo<'Value> * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
<Extension()>
Public Function PostAsJsonAsync(Of TValue) (client As HttpClient, requestUri As Uri, value As TValue, jsonTypeInfo As JsonTypeInfo(Of TValue), Optional cancellationToken As CancellationToken = Nothing) As Task(Of HttpResponseMessage)

Type Parameters

TValue

The type of the value to serialize.

Parameters

client
HttpClient

The client used to send the request.

requestUri
Uri

The Uri the request is sent to.

value
TValue

The value to serialize.

jsonTypeInfo
JsonTypeInfo<TValue>

The JsonTypeInfo used to control the serialization behavior.

cancellationToken
CancellationToken

A cancellation token that can be used by other objects or threads to receive notice of cancellation.

Returns

The task object representing the asynchronous operation.

Exceptions

The cancellation token was canceled. This exception is stored into the returned task.

Applies to