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

New Post: POST method syntax

$
0
0
Hi Steven,

I'm not sure which version you are using but in 2.3.0 we added some overloads on Windows to work with UTF-8 strings with the http_client using the correct http_client::request overload. It looks like you are missing the path portion and should be able to directly pass the std::string. Try something like the following:
http_response response = client.request(methods::POST, "path", data).get();
If you want to upload from a file, instead of reading first into a string it probably would be more efficient to directly open a stream to the file and use that instead. Here is the correct http_client::request overload. Try something like the following:
auto stream = concurrency::streams::file_buffer<uint8_t>::open(U("filename"), std::ios_base::in).get();
http_response response = client.request(methods::POST, U"path", stream, U("content type")).get();
Also in the future please open up a new discussion thread as opposed to recycling an older one.

Thanks,
Steve

Viewing all articles
Browse latest Browse all 4845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>