Sending POST request using libcurl C++. I have tried almost all combination except the right one which I could not figure out.
curl_easy_setopt(curl, CURLOPT_URL, url.c_str()); curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, FALSE); /*Not Recommended to use but since certificates are not available this is a workaround added*/ curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, FALSE); /*Not Recommended to use but since certificates are not available this is a workaround added*/ curl_easy_setopt(curl, CURLOPT_HTTPPOST, TRUE); //CURLOPT_POST does not work as well curl_easy_setopt(curl, CURLOPT_POSTFIELDS, sJson); curl_easy_setopt(curl, CURLOPT_WRITEFUNCTION, bytesCallback); curl_easy_setopt(curl, CURLOPT_WRITEDATA, &readBuffer); curl_easy_setopt(curl, CURLOPT_HEADERFUNCTION, bytesCallback); curl_easy_setopt(curl, CURLOPT_HEADERDATA, &headBuffer); sJson is a std::string which has the body that is created by pb2json.
I cannot figure out why the body is not sent ? Is there some API i am missing if libcurl, any lead is appreciated !
Received login request with no bodyCURLOPT_POSTdoes not work