HttpClient.TryPostAsync(Uri, IHttpContent) HttpClient.TryPostAsync(Uri, IHttpContent) HttpClient.TryPostAsync(Uri, IHttpContent) HttpClient.TryPostAsync(Uri, IHttpContent) HttpClient.TryPostAsync(Uri, IHttpContent) Method

Definition

Sends a POST request to the specified Uri as an asynchronous operation.

public : IAsyncOperationWithProgress<HttpRequestResult, HttpProgress> TryPostAsync(Uri uri, IHttpContent content)
IAsyncOperationWithProgress<HttpRequestResult, HttpProgress> TryPostAsync(Uri uri, IHttpContent content) const;
public IAsyncOperationWithProgress<HttpRequestResult, HttpProgress> TryPostAsync(Uri uri, IHttpContent content)
Public Function TryPostAsync(uri As Uri, content As IHttpContent) As IAsyncOperationWithProgress(Of HttpRequestResultHttpProgress)
Windows.Web.Http.HttpClient.tryPostAsync(uri, content).done( /* Your success and error handlers */ );

Parameters

uri
Uri Uri Uri

The Uri the request is sent to.

content
IHttpContent IHttpContent IHttpContent

The HTTP request content to send to the server.

Returns

Additional features and requirements

Device family
Windows 10, version 1903 (introduced v10.0.18362.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v8)

Remarks

This operation will not throw an exception on network errors. Instead you should examine the HttpRequestResult to learn about the original HTTP request, the resulting HTTP response (if any) and error (if any). This operation will throw when the operation is canceled.

This operation will not block. The returned IAsyncOperationWithProgress(HttpRequestResult,HttpProgress) object will complete after the whole response (including content) is read.

The TryPutAsync and TryPostAsync methods only allow setting a limited number of HTTP content headers. In contrast, the TrySendRequestAsync method allows setting headers on the request message as well as on the HTTP content to be sent.

See also