locked
How can I send parameters when I used HttpRequest Post in HttpClient sample?

    Question

  • in the sample,we can see these:

    task<wstring> HttpRequest::PostAsync(Uri^ uri, const wstring& body, cancellation_token cancellationToken)

    {

    .....

    }

    so , I have some parameters, how can I send them? I dont understand the meaning of "body" .


    • Edited by ruby1989 Thursday, November 1, 2012 11:56 AM
    Thursday, November 1, 2012 11:56 AM

Answers

  • Hello,

    The body parameter that you are looking at is the entity body of the HTTP POST request. In the HttpClient sample, if you run Scenario4, the body is essentially the "Hello World" word. Once you have an entity body to send, you will need to copy it into a stream and then use the IXMLHttpRequest2::Send function to send the entity body.

    Thanks,

    Prashant.

    Friday, November 2, 2012 9:05 PM
    Moderator

All replies

  • Hello,

    The body parameter that you are looking at is the entity body of the HTTP POST request. In the HttpClient sample, if you run Scenario4, the body is essentially the "Hello World" word. Once you have an entity body to send, you will need to copy it into a stream and then use the IXMLHttpRequest2::Send function to send the entity body.

    Thanks,

    Prashant.

    Friday, November 2, 2012 9:05 PM
    Moderator
  • New in Windows 8.1: the Windows.Web.Http HttpClient API.  This is an easy-to-use, full-featured HTTP API that works in all languages: C++, .NET (C#, VB) and JavaScript.    Advantages of the new API include: strongly typed headers (meaning: you write fewer bugs in less time), full support for standard WinRT async concepts and data types.

    HttpClient also lets you inject your modular filter code into the HTTP processing pipeline, letting you handle logging, testing, retry and auth more naturally.  Samples of filters include retry and metered network filters in the HttpClient sample, and OAUTH and OAUTH 2.0 support in the Web Authentication Broker sample.

    (Note that the existing IXHR2 code is still available for developers, and your existing Windows 8 code should continue to work as expected)

    There's a //build/ 2013 video for the new API at http://channel9.msdn.com/Events/Build/2013/4-092

    We also have samples at http://code.msdn.microsoft.com/windowsapps/HttpClient-sample-55700664

    There's an OAUTH 0 filter sample at http://code.msdn.microsoft.com/windowsapps/Web-Authentication-d0485122

    And there's documentation at http://msdn.microsoft.com/en-us/library/windows/apps/windows.web.http.aspx


    Network Developer Experience Team (Microsoft)

    Tuesday, July 16, 2013 9:25 PM