microsoft / cpprestsdk

The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
Other
7.97k stars 1.65k forks source link

Failed to create web::http::client::http_client object in 32 bit C++ MFC application in windows #1626

Open debasis09 opened 3 years ago

debasis09 commented 3 years ago

I am creating MFC application in VS2015 target m/c X86.So using cpprest_2_10.lib and cpprest_2_10.dll which I have downloaded through "vcpkg install cpprestsdk cpprestsdk:x86-windows" this command. Now the compilation is successful and application starts running but the 1st issue I am facing is that not able to create web::http::client::http_client object which I am going to use in a POST call. I have written my code like

utility::string_t url = _XPLATSTR("https://login.microsoftonline.com"); web::http::client::http_client client(url); //this line throwing me the below error

"Unhandled exception at 0x7658A6E2 in MFCApplicationClient.exe: Microsoft C++ exception: std::invalid_argument at memory location 0x004FF3C4."

when I am trying to debug this application and going inside the constructor of http_client I am seeing that it is receiving some junk characters inside constructor though I am sending a valid url.

in my MFC application proj setting character set is "Use Unicode Character Set". Can you please help me out. I can not use 64 bit cpprestsdk because my actual application is 32 bit MFC application

pjbruce commented 3 years ago

You can use vcpkg install cpprest. In my test, cpprest is no problem. Please turn on / Zc: wchar_t.