cpprestsdk
cpprestsdk copied to clipboard
Unhandled exception about an invalid parameter
I got an exception about an invalid parameter to a function that considers such parameters fatal, when trying to run the app made using the source code HTTP Client Getting Started Tutorial. In the file ucrtbased.dll. The function is _Deallocate().
My code is just as the source code given in the tutorial, except I left out the "return 0;" at the end:
// Osman Zakir
// 11 / 1 / 2017
// cpprestsdk, Casablanca Getting Started Tutorial application
// taking a look at how to use our http_client to connect to a server and download some data
#include <cpprest\http_client.h>
#include <cpprest\filestream.h>
using namespace utility;
using namespace web;
using namespace web::http;
using namespace web::http::client;
using namespace concurrency::streams;
int main(int argc, char* argv[])
{
auto fileStream = std::make_shared<ostream>();
// Open stream to output file.
pplx::task<void> requestTask = fstream::open_ostream(U("results.html")).then([=](ostream outFile)
{
*fileStream = outFile;
// Create http_client to send the request.
http_client client(U("http://www.bing.com/"));
// Build request URI and start the request.
uri_builder builder(U("/search"));
builder.append_query(U("q"), U("cpprestsdk github"));
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());
}
}
So how do I get rid of the exception?
Honestly Microsoft, if you want us to invest in the Azure Cloud and in your services in general you just have to respond to basic questions like this. I have exactly the same error using your provided sample which i even consider a success because in x64 i immediatly get a read access violation. (yes i am using the x64 libs of both boost and cpprest). As soon as we get the basic functions working we can figure our way through all this, but if not even the samples run it is just bad.
same here