C++
C++
Transition from Http.PostJson2 to Http.HttpStr
Provides instructions for replacing deprecated PostJson2 method calls with HttpStr.Chilkat C++ Downloads
#include <CkHttp.h>
#include <CkHttpResponse.h>
void ChilkatSample(void)
{
bool success = false;
CkHttp http;
const char *url = "https://example.com/something";
const char *contentType = "application/json";
const char *jsonText = "{ ... }";
// ------------------------------------------------------------------------
// The PostJson2 method is deprecated:
CkHttpResponse *responseObj = http.PostJson2(url,contentType,jsonText);
if (http.get_LastMethodSuccess() == false) {
std::cout << http.lastErrorText() << "\r\n";
return;
}
// ...
// ...
delete responseObj;
// ------------------------------------------------------------------------
// Do the equivalent using HttpStr.
// Your application creates a new, empty HttpResponse object which is passed
// in the last argument and filled upon success.
CkHttpResponse responseOut;
success = http.HttpStr("POST",url,jsonText,"utf-8",contentType,responseOut);
if (success == false) {
std::cout << http.lastErrorText() << "\r\n";
return;
}
}