Quantcast
Channel: WE MOVED to github.com/microsoft/cpprestsdk. This site is not monitored!
Viewing all articles
Browse latest Browse all 4845

New Post: how to combine the url with c++ rest sdk?

$
0
0
sorry, I have lost the builder part, here is the total program:
void main()
{
    auto fileStream = std::make_shared<ostream>();
    pplx::task<void> requestTask = fstream::open_ostream(U("results.html")).then([=](ostream outFile)
  {
      http_client client(U("http://221.231.139.132:9999/eps-ws/rest/AccountService/")); 
      //here is the function name and the 4  input parameters of the function:
      std::wstring functionname = U("login"); 
      std::wstring username = U("test1"); 
      std::wstring password = U("123456"); 
      std::wstring sourceType= U("1"); 
      std::wstring description= U("test"); 

      std::wstring accounturl = functionname + U("/") + username + U("/") +
       password + U("/") + sourceType+ U("/") + description+ U("/"); 
      uri_builder builder(accounturl);
      return client.request(methods::GET, builder.to_string()); 
  })


// Handle response headers arriving.
  .then([=](http_response response)
  {
      printf("Received response status code:%u\n", response.status_code());
      // Write response body into the file.
      return response.body().read_to_end(fileStream->streambuf());
  })

  // Close the file stream.
    .then([=](size_t)
  {
      return fileStream->close();
   });

  // Wait for all the outstanding I/O to complete and handle any exceptions
  try
  {
    requestTask.wait();
  }
  catch (const std::exception &e)
  {
    printf("Error exception:%s\n", e.what());
  }
}


Viewing all articles
Browse latest Browse all 4845

Trending Articles