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

Definition

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

public : IAsyncOperationWithProgress<HttpResponseMessage, HttpProgress> PostAsync(Uri uri, IHttpContent content)
IAsyncOperationWithProgress<HttpResponseMessage, HttpProgress> PostAsync(Uri uri, IHttpContent content) const;
public IAsyncOperationWithProgress<HttpResponseMessage, HttpProgress> PostAsync(Uri uri, IHttpContent content)
Public Function PostAsync(uri As Uri, content As IHttpContent) As IAsyncOperationWithProgress(Of HttpResponseMessageHttpProgress)
Windows.Web.Http.HttpClient.postAsync(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

Remarks

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

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

Below are the exceptions that this function throws.

E_INVALIDARG

The uri parameter was a null reference (Nothing in Visual Basic).

Exception Handling

You must write code to handle exceptions when you call this method. Exceptions can result from parameter validation errors, name resolutions failures, and network errors. Exceptions from network errors (loss of connectivity, connection failures, and HTTP server failures, for example) can happen at any time. These errors result in exceptions being thrown. If not handled by your app, an exception can cause your entire app to be terminated by the runtime. For more information on how to handle exceptions, see Handling exceptions in network apps.

See Also