Skip to main content
HttpClient.GetBufferAsync | getBufferAsync method

Send a GET request to the specified Uri and return the response body as a buffer in an asynchronous operation.


httpClient.getBufferAsync(uri).done( /* Your success and error handlers */ );

public IAsyncOperationWithProgress<IBuffer, HttpProgress> GetBufferAsync(
  Uri uri

Public Function GetBufferAsync(
  uri As Uri 
) As IAsyncOperationWithProgress(Of IBuffer, HttpProgress)

IAsyncOperationWithProgress<IBuffer, HttpProgress>^ GetBufferAsync(
  Uri^ uri



Type: Windows.Foundation.Uri [JavaScript] | System.Uri [.NET] | Windows::Foundation::Uri [C++]

The Uri the request is sent to.

Return value

Type: IAsyncOperationWithProgress<IBuffer, HttpProgress>

The object representing the asynchronous operation.


A number of exceptions can occur when calling this method. Only a few of the possible errors that can cause exceptions are listed.

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.

An app can use the HRESULT from the exception to learn more detailed information on the error that caused the exception.

For more information on possible exceptions and how to handle exceptions, see Handling exceptions in network apps.


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


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

The HttpClient class is often used by an app to download and then parse text. It is possible that the character encoding specified in the Content-Type header by an HTTP server does not match the character encoding of the HTTP response body (the XML encoding in an XML document, for example). One way to use HttpClient with text is to call the GetStringAsync method and pass the returned string to the text parser. However, this can result in errors if the Content-Type is not a type expressible as a string. A reliable way to use HttpClient with an XML parser is to call the GetBufferAsync method and parse the buffer for the "<?xml>" element. Then use the character encoding specified ("<xmlversion="1.0" encoding="UTF-8"?>", for example) to parse the HTTP response body. For other text formats, similar methods can be used where the app scans the initial part of the HTTP response body to determine the character encoding used.

Requirements (Windows 10 device family)

Device family

Universal, introduced version 10.0.10240.0

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0


Windows::Web::Http [C++]



Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8.1

Minimum supported server

Windows Server 2012 R2

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]


Windows::Web::Http [C++]



See also

IAsyncOperationWithProgress(IBuffer, HttpProgress)