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

New Post: Running into "error in WinHttpSendRequest" when making https requests

$
0
0
Hi,

I use casablanca to build a cpp rest client. Recently we need to replace all http requests with https requests. So I simply changed the "http" in the following code to "https":
        //vistit https://api.dropbox.com/1/account/info

        http_client_config config1;
        credentials cred = credentials(U("ADMIN"),U("ADMIN"));
        config1.set_credentials(cred);

        http_client session(U("https://api.dropbox.com"), config1);
        http_request request;
        std::string requestBody = "{\"abc\" : \"efg\"}";

        request.set_method(methods::POST);
        request.set_request_uri(uri(U("/1/account/info")));
        request.set_body(requestBody, L"application/json");

        try
        {
            http_response response = session.request(request).get();
        }
        catch(std::exception& e)
        {
            printf(e.what());
        }
I downloaded the lastest source code on the official website to run the above query. an exception is thrown at the try clause, and it prints "error in WinHttpSendRequest" I'm wondering what is the cause of this problem? My code works for non-http situations.

thanks very much!

Viewing all articles
Browse latest Browse all 4845

Latest Images

Trending Articles



Latest Images

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