Skip to content

Latest commit

 

History

History
52 lines (29 loc) · 2.8 KB

httpclient_postasync_1466488101.md

File metadata and controls

52 lines (29 loc) · 2.8 KB
-api-id -api-type
M:Windows.Web.Http.HttpClient.PostAsync(Windows.Foundation.Uri,Windows.Web.Http.IHttpContent)
winrt method

Windows.Web.Http.HttpClient.PostAsync

-description

Send a POST request to the specified URI as an asynchronous operation. For programming guidance for the HttpClient class, and code examples, see the HttpClient conceptual topic.

-parameters

-param uri

The URI the request is sent to.

-param content

The HTTP request content to send to the server.

-returns

The object representing the asynchronous operation.

-remarks

This operation will not block. The returned IAsyncOperationWithProgress (ofHttpResponseMessage and HttpProgress) completes 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.

-examples

See HttpClient for examples of calling HttpClient.PostAsync.

-see-also

IHttpContent, IAsyncOperationWithProgress, HttpResponseMessage, HttpProgress, PutAsync, SendRequestAsync, Uri, HttpClient