Share via


HttpClientExtensions.PostAsJsonAsync Method

 

Namespace:   System.Net.Http
Assembly:  System.Net.Http.Formatting (in System.Net.Http.Formatting.dll)

Overload List

Name Description
System_CAPS_pubmethodSystem_CAPS_static PostAsJsonAsync<T>(HttpClient, String, T)

System_CAPS_pubmethodSystem_CAPS_static PostAsJsonAsync<T>(HttpClient, String, T, CancellationToken)

System_CAPS_pubmethodSystem_CAPS_static PostAsJsonAsync<T>(HttpClient, Uri, T)

Sends a POST request as an asynchronous operation to the specified Uri with the given value serialized as JSON.

System_CAPS_pubmethodSystem_CAPS_static PostAsJsonAsync<T>(HttpClient, Uri, T, CancellationToken)

Sends a POST request as an asynchronous operation to the specified Uri with the given value serialized as JSON.

See Also

HttpClientExtensions Class
System.Net.Http Namespace

Return to top

HttpClientExtensions.PostAsJsonAsync<T> Method (HttpClient, String, T)

Syntax

public static Task<HttpResponseMessage> PostAsJsonAsync<T>(
    this HttpClient client,
    string requestUri,
    T value
)
public:
generic<typename T>
[ExtensionAttribute]
static Task<HttpResponseMessage^>^ PostAsJsonAsync(
    HttpClient^ client,
    String^ requestUri,
    T value
)
static member PostAsJsonAsync<'T> : 
        client:HttpClient *
        requestUri:string *
        value:'T -> Task<HttpResponseMessage>
<ExtensionAttribute>
Public Shared Function PostAsJsonAsync(Of T) (
    client As HttpClient,
    requestUri As String,
    value As T
) As Task(Of HttpResponseMessage)

Parameters

  • value
    Type: T

Return Value

Type: System.Threading.Tasks.Task<HttpResponseMessage>

Type Parameters

  • T

Return to top

HttpClientExtensions.PostAsJsonAsync<T> Method (HttpClient, String, T, CancellationToken)

Syntax

public static Task<HttpResponseMessage> PostAsJsonAsync<T>(
    this HttpClient client,
    string requestUri,
    T value,
    CancellationToken cancellationToken
)
public:
generic<typename T>
[ExtensionAttribute]
static Task<HttpResponseMessage^>^ PostAsJsonAsync(
    HttpClient^ client,
    String^ requestUri,
    T value,
    CancellationToken cancellationToken
)
static member PostAsJsonAsync<'T> : 
        client:HttpClient *
        requestUri:string *
        value:'T *
        cancellationToken:CancellationToken -> Task<HttpResponseMessage>
<ExtensionAttribute>
Public Shared Function PostAsJsonAsync(Of T) (
    client As HttpClient,
    requestUri As String,
    value As T,
    cancellationToken As CancellationToken
) As Task(Of HttpResponseMessage)

Parameters

  • value
    Type: T

Return Value

Type: System.Threading.Tasks.Task<HttpResponseMessage>

Type Parameters

  • T

Return to top

HttpClientExtensions.PostAsJsonAsync<T> Method (HttpClient, Uri, T)

Sends a POST request as an asynchronous operation to the specified Uri with the given value serialized as JSON.

Syntax

public static Task<HttpResponseMessage> PostAsJsonAsync<T>(
    this HttpClient client,
    Uri requestUri,
    T value
)
public:
generic<typename T>
[ExtensionAttribute]
static Task<HttpResponseMessage^>^ PostAsJsonAsync(
    HttpClient^ client,
    Uri^ requestUri,
    T value
)
static member PostAsJsonAsync<'T> : 
        client:HttpClient *
        requestUri:Uri *
        value:'T -> Task<HttpResponseMessage>
<ExtensionAttribute>
Public Shared Function PostAsJsonAsync(Of T) (
    client As HttpClient,
    requestUri As Uri,
    value As T
) As Task(Of HttpResponseMessage)

Parameters

  • requestUri
    Type: System.Uri

    The Uri the request is sent to.

  • value
    Type: T

    The value that will be placed in the request's entity body.

Return Value

Type: System.Threading.Tasks.Task<HttpResponseMessage>

A task object representing the asynchronous operation.

Type Parameters

  • T
    The type of value.

Return to top

HttpClientExtensions.PostAsJsonAsync<T> Method (HttpClient, Uri, T, CancellationToken)

Sends a POST request as an asynchronous operation to the specified Uri with the given value serialized as JSON.

Syntax

public static Task<HttpResponseMessage> PostAsJsonAsync<T>(
    this HttpClient client,
    Uri requestUri,
    T value,
    CancellationToken cancellationToken
)
public:
generic<typename T>
[ExtensionAttribute]
static Task<HttpResponseMessage^>^ PostAsJsonAsync(
    HttpClient^ client,
    Uri^ requestUri,
    T value,
    CancellationToken cancellationToken
)
static member PostAsJsonAsync<'T> : 
        client:HttpClient *
        requestUri:Uri *
        value:'T *
        cancellationToken:CancellationToken -> Task<HttpResponseMessage>
<ExtensionAttribute>
Public Shared Function PostAsJsonAsync(Of T) (
    client As HttpClient,
    requestUri As Uri,
    value As T,
    cancellationToken As CancellationToken
) As Task(Of HttpResponseMessage)

Parameters

  • requestUri
    Type: System.Uri

    The Uri the request is sent to.

  • value
    Type: T

    The value that will be placed in the request's entity body.

Return Value

Type: System.Threading.Tasks.Task<HttpResponseMessage>

A task object representing the asynchronous operation.

Type Parameters

  • T
    The type of value.

Return to top