HttpClientJsonExtensions.PutAsJsonAsync 方法

定義

多載

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

將 PUT 要求傳送至指定的 URI,其中包含在要求主體中序列化為 JSON 的 valueSend a PUT request to the specified Uri containing the value serialized as JSON in the request body.

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

將 PUT 要求傳送至指定的 URI,其中包含在要求主體中序列化為 JSON 的 valueSend a PUT request to the specified Uri containing the value serialized as JSON in the request body.

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

將 PUT 要求傳送至指定的 URI,其中包含在要求主體中序列化為 JSON 的 valueSend a PUT request to the specified Uri containing the value serialized as JSON in the request body.

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

將 PUT 要求傳送至指定的 URI,其中包含在要求主體中序列化為 JSON 的 valueSend a PUT request to the specified Uri containing the value serialized as JSON in the request body.

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

將 PUT 要求傳送至指定的 URI,其中包含在要求主體中序列化為 JSON 的 valueSend a PUT 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 ^> ^ PutAsJsonAsync(System::Net::Http::HttpClient ^ client, System::String ^ requestUri, TValue value, System::Threading::CancellationToken cancellationToken);
public static System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> PutAsJsonAsync<TValue> (this System.Net.Http.HttpClient client, string? requestUri, TValue value, System.Threading.CancellationToken cancellationToken);
static member PutAsJsonAsync : System.Net.Http.HttpClient * string * 'Value * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
<Extension()>
Public Function PutAsJsonAsync(Of TValue) (client As HttpClient, requestUri As String, value As TValue, cancellationToken As CancellationToken) As Task(Of HttpResponseMessage)

類型參數

TValue

要序列化之值的類型。The type of the value to serialize.

參數

client
HttpClient

用來傳送要求的用戶端。The client used to send the request.

requestUri
String

傳送要求的目標 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.

傳回

Task<HttpResponseMessage>

工作物件,表示非同步作業。The task object representing the asynchronous operation.

備註

這個方法 JsonSerializerDefaults.Web 會使用序列化的選項,而 JsonSerializer 序列化方法預設不會。This method uses JsonSerializerDefaults.Web options for serialization, whereas JsonSerializer serialization methods do not, by default.

適用於

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

將 PUT 要求傳送至指定的 URI,其中包含在要求主體中序列化為 JSON 的 valueSend a PUT 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 ^> ^ PutAsJsonAsync(System::Net::Http::HttpClient ^ client, Uri ^ requestUri, TValue value, System::Threading::CancellationToken cancellationToken);
public static System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage> PutAsJsonAsync<TValue> (this System.Net.Http.HttpClient client, Uri? requestUri, TValue value, System.Threading.CancellationToken cancellationToken);
static member PutAsJsonAsync : System.Net.Http.HttpClient * Uri * 'Value * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
<Extension()>
Public Function PutAsJsonAsync(Of TValue) (client As HttpClient, requestUri As Uri, value As TValue, cancellationToken As CancellationToken) As Task(Of HttpResponseMessage)

類型參數

TValue

要序列化之值的類型。The type of the value to serialize.

參數

client
HttpClient

用來傳送要求的用戶端。The client used to send the request.

requestUri
Uri

傳送要求的目標 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.

傳回

Task<HttpResponseMessage>

工作物件,表示非同步作業。The task object representing the asynchronous operation.

備註

這個方法 JsonSerializerDefaults.Web 會使用序列化的選項,而 JsonSerializer 序列化方法預設不會。This method uses JsonSerializerDefaults.Web options for serialization, whereas JsonSerializer serialization methods do not, by default.

適用於

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

將 PUT 要求傳送至指定的 URI,其中包含在要求主體中序列化為 JSON 的 valueSend a PUT 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> PutAsJsonAsync<TValue> (this System.Net.Http.HttpClient client, string? requestUri, TValue value, System.Text.Json.JsonSerializerOptions? options = default, System.Threading.CancellationToken cancellationToken = default);
static member PutAsJsonAsync : System.Net.Http.HttpClient * string * 'Value * System.Text.Json.JsonSerializerOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
<Extension()>
Public Function PutAsJsonAsync(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)

類型參數

TValue

要序列化之值的類型。The type of the value to serialize.

參數

client
HttpClient

用來傳送要求的用戶端。The client used to send the request.

requestUri
String

傳送要求的目標 URI。The Uri the request is sent to.

value
TValue

要序列化的值。The value to serialize.

options
JsonSerializerOptions

在序列化期間控制行為的選項。Options to control the behavior during serialization. 預設選項是 Web 所指定的選項。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.

傳回

Task<HttpResponseMessage>

工作物件,表示非同步作業。The task object representing the asynchronous operation.

適用於

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

將 PUT 要求傳送至指定的 URI,其中包含在要求主體中序列化為 JSON 的 valueSend a PUT 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> PutAsJsonAsync<TValue> (this System.Net.Http.HttpClient client, Uri? requestUri, TValue value, System.Text.Json.JsonSerializerOptions? options = default, System.Threading.CancellationToken cancellationToken = default);
static member PutAsJsonAsync : System.Net.Http.HttpClient * Uri * 'Value * System.Text.Json.JsonSerializerOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
<Extension()>
Public Function PutAsJsonAsync(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)

類型參數

TValue

要序列化之值的類型。The type of the value to serialize.

參數

client
HttpClient

用來傳送要求的用戶端。The client used to send the request.

requestUri
Uri

傳送要求的目標 URI。The Uri the request is sent to.

value
TValue

要序列化的值。The value to serialize.

options
JsonSerializerOptions

在序列化期間控制行為的選項。Options to control the behavior during serialization. 預設選項是 Web 所指定的選項。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.

傳回

Task<HttpResponseMessage>

工作物件,表示非同步作業。The task object representing the asynchronous operation.

適用於