HttpClientJsonExtensions.PostAsJsonAsync Methode
Definitie
Belangrijk
Bepaalde informatie heeft betrekking op een voorlopige productversie die aanzienlijk kan worden gewijzigd voordat deze wordt uitgebracht. Microsoft biedt geen enkele expliciete of impliciete garanties met betrekking tot de informatie die hier wordt verstrekt.
Overloads
| Name | Description |
|---|---|
| PostAsJsonAsync<TValue>(HttpClient, String, TValue, CancellationToken) |
Verzendt een POST-aanvraag naar de opgegeven URI die de |
| PostAsJsonAsync<TValue>(HttpClient, Uri, TValue, CancellationToken) |
Verzendt een POST-aanvraag naar de opgegeven URI die de |
| PostAsJsonAsync<TValue>(HttpClient, String, TValue, JsonSerializerOptions, CancellationToken) |
Verzendt een POST-aanvraag naar de opgegeven URI die de |
| PostAsJsonAsync<TValue>(HttpClient, String, TValue, JsonTypeInfo<TValue>, CancellationToken) |
Verzendt een POST-aanvraag naar de opgegeven URI die de |
| PostAsJsonAsync<TValue>(HttpClient, Uri, TValue, JsonSerializerOptions, CancellationToken) |
Verzendt een POST-aanvraag naar de opgegeven URI die de |
| PostAsJsonAsync<TValue>(HttpClient, Uri, TValue, JsonTypeInfo<TValue>, CancellationToken) |
Verzendt een POST-aanvraag naar de opgegeven URI die de |
PostAsJsonAsync<TValue>(HttpClient, String, TValue, CancellationToken)
Verzendt een POST-aanvraag naar de opgegeven URI die de value geserialiseerde als JSON in de aanvraagbody bevat.
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);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
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);
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);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
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);
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext.")>]
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")>]
static member PostAsJsonAsync : System.Net.Http.HttpClient * string * 'Value * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
static member PostAsJsonAsync : System.Net.Http.HttpClient * string * 'Value * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")>]
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
Het type van de waarde dat moet worden geserialiseerd.
Parameters
- client
- HttpClient
De client die wordt gebruikt om de aanvraag te verzenden.
- requestUri
- String
De URI waar de aanvraag naar wordt verzonden.
- value
- TValue
De waarde die moet worden geserialiseerd.
- cancellationToken
- CancellationToken
Een annuleringstoken dat kan worden gebruikt door andere objecten of threads om kennisgeving van annulering te ontvangen.
Retouren
Het taakobject dat de asynchrone bewerking vertegenwoordigt.
- Kenmerken
Uitzonderingen
Het annuleringstoken is geannuleerd. Deze uitzondering wordt opgeslagen in de geretourneerde taak.
Opmerkingen
Deze methode maakt gebruik van JsonSerializerDefaults.Web opties voor serialisatie, terwijl JsonSerializer serialisatiemethoden niet standaard.
Van toepassing op
PostAsJsonAsync<TValue>(HttpClient, Uri, TValue, CancellationToken)
Verzendt een POST-aanvraag naar de opgegeven URI die de value geserialiseerde als JSON in de aanvraagbody bevat.
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);
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
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);
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);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
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);
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext.")>]
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")>]
static member PostAsJsonAsync : System.Net.Http.HttpClient * Uri * 'Value * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
static member PostAsJsonAsync : System.Net.Http.HttpClient * Uri * 'Value * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")>]
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
Het type van de waarde dat moet worden geserialiseerd.
Parameters
- client
- HttpClient
De client die wordt gebruikt om de aanvraag te verzenden.
- requestUri
- Uri
De URI waar de aanvraag naar wordt verzonden.
- value
- TValue
De waarde die moet worden geserialiseerd.
- cancellationToken
- CancellationToken
Een annuleringstoken dat kan worden gebruikt door andere objecten of threads om kennisgeving van annulering te ontvangen.
Retouren
Het taakobject dat de asynchrone bewerking vertegenwoordigt.
- Kenmerken
Uitzonderingen
Het annuleringstoken is geannuleerd. Deze uitzondering wordt opgeslagen in de geretourneerde taak.
Opmerkingen
Deze methode maakt gebruik van JsonSerializerDefaults.Web opties voor serialisatie, terwijl JsonSerializer serialisatiemethoden niet standaard.
Van toepassing op
PostAsJsonAsync<TValue>(HttpClient, String, TValue, JsonSerializerOptions, CancellationToken)
Verzendt een POST-aanvraag naar de opgegeven URI die de value geserialiseerde als JSON in de aanvraagbody bevat.
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
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);
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);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
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);
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext.")>]
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")>]
static member PostAsJsonAsync : System.Net.Http.HttpClient * string * 'Value * System.Text.Json.JsonSerializerOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
static member PostAsJsonAsync : System.Net.Http.HttpClient * string * 'Value * System.Text.Json.JsonSerializerOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")>]
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
Het type van de waarde dat moet worden geserialiseerd.
Parameters
- client
- HttpClient
De client die wordt gebruikt om de aanvraag te verzenden.
- requestUri
- String
De URI waar de aanvraag naar wordt verzonden.
- value
- TValue
De waarde die moet worden geserialiseerd.
- options
- JsonSerializerOptions
Opties voor het beheren van het gedrag tijdens serialisatie. De standaardopties zijn de opties die zijn opgegeven door Web.
- cancellationToken
- CancellationToken
Een annuleringstoken dat kan worden gebruikt door andere objecten of threads om kennisgeving van annulering te ontvangen.
Retouren
Het taakobject dat de asynchrone bewerking vertegenwoordigt.
- Kenmerken
Uitzonderingen
Het annuleringstoken is geannuleerd. Deze uitzondering wordt opgeslagen in de geretourneerde taak.
Van toepassing op
PostAsJsonAsync<TValue>(HttpClient, String, TValue, JsonTypeInfo<TValue>, CancellationToken)
Verzendt een POST-aanvraag naar de opgegeven URI die de value geserialiseerde als JSON in de aanvraagbody bevat.
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
Het type van de waarde dat moet worden geserialiseerd.
Parameters
- client
- HttpClient
De client die wordt gebruikt om de aanvraag te verzenden.
- requestUri
- String
De URI waar de aanvraag naar wordt verzonden.
- value
- TValue
De waarde die moet worden geserialiseerd.
- jsonTypeInfo
- JsonTypeInfo<TValue>
De JsonTypeInfo die wordt gebruikt om het serialisatiegedrag te beheren.
- cancellationToken
- CancellationToken
Een annuleringstoken dat kan worden gebruikt door andere objecten of threads om kennisgeving van annulering te ontvangen.
Retouren
Het taakobject dat de asynchrone bewerking vertegenwoordigt.
Uitzonderingen
Het annuleringstoken is geannuleerd. Deze uitzondering wordt opgeslagen in de geretourneerde taak.
Van toepassing op
PostAsJsonAsync<TValue>(HttpClient, Uri, TValue, JsonSerializerOptions, CancellationToken)
Verzendt een POST-aanvraag naar de opgegeven URI die de value geserialiseerde als JSON in de aanvraagbody bevat.
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext.")]
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
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);
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);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")]
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);
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext.")>]
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")>]
static member PostAsJsonAsync : System.Net.Http.HttpClient * Uri * 'Value * System.Text.Json.JsonSerializerOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
static member PostAsJsonAsync : System.Net.Http.HttpClient * Uri * 'Value * System.Text.Json.JsonSerializerOptions * System.Threading.CancellationToken -> System.Threading.Tasks.Task<System.Net.Http.HttpResponseMessage>
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("JSON serialization and deserialization might require types that cannot be statically analyzed. Use the overload that takes a JsonTypeInfo or JsonSerializerContext, or make sure all of the required types are preserved.")>]
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
Het type van de waarde dat moet worden geserialiseerd.
Parameters
- client
- HttpClient
De client die wordt gebruikt om de aanvraag te verzenden.
- requestUri
- Uri
De URI waar de aanvraag naar wordt verzonden.
- value
- TValue
De waarde die moet worden geserialiseerd.
- options
- JsonSerializerOptions
Opties voor het beheren van het gedrag tijdens serialisatie. De standaardopties zijn de opties die zijn opgegeven door Web.
- cancellationToken
- CancellationToken
Een annuleringstoken dat kan worden gebruikt door andere objecten of threads om kennisgeving van annulering te ontvangen.
Retouren
Het taakobject dat de asynchrone bewerking vertegenwoordigt.
- Kenmerken
Uitzonderingen
Het annuleringstoken is geannuleerd. Deze uitzondering wordt opgeslagen in de geretourneerde taak.
Van toepassing op
PostAsJsonAsync<TValue>(HttpClient, Uri, TValue, JsonTypeInfo<TValue>, CancellationToken)
Verzendt een POST-aanvraag naar de opgegeven URI die de value geserialiseerde als JSON in de aanvraagbody bevat.
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
Het type van de waarde dat moet worden geserialiseerd.
Parameters
- client
- HttpClient
De client die wordt gebruikt om de aanvraag te verzenden.
- requestUri
- Uri
De URI waar de aanvraag naar wordt verzonden.
- value
- TValue
De waarde die moet worden geserialiseerd.
- jsonTypeInfo
- JsonTypeInfo<TValue>
De JsonTypeInfo die wordt gebruikt om het serialisatiegedrag te beheren.
- cancellationToken
- CancellationToken
Een annuleringstoken dat kan worden gebruikt door andere objecten of threads om kennisgeving van annulering te ontvangen.
Retouren
Het taakobject dat de asynchrone bewerking vertegenwoordigt.
Uitzonderingen
Het annuleringstoken is geannuleerd. Deze uitzondering wordt opgeslagen in de geretourneerde taak.