Unicode C++
Unicode C++
Transition from Http.PostJson3 to Http.HttpJson
Provides instructions for replacing deprecated PostJson3 method calls with HttpJson.Chilkat Unicode C++ Downloads
#include <CkHttpW.h>
#include <CkJsonObjectW.h>
#include <CkHttpResponseW.h>
void ChilkatSample(void)
{
bool success = false;
CkHttpW http;
const wchar_t *url = L"https://example.com/something";
const wchar_t *contentType = L"application/json";
CkJsonObjectW json;
json.LoadFile(L"C:/temp/requestBody.json");
// ------------------------------------------------------------------------
// The PostJson3 method is deprecated:
CkHttpResponseW *responseObj = http.PostJson3(url,contentType,json);
if (http.get_LastMethodSuccess() == false) {
wprintf(L"%s\n",http.lastErrorText());
return;
}
// ...
// ...
delete responseObj;
// ------------------------------------------------------------------------
// Do the equivalent using HttpJson.
// Your application creates a new, empty HttpResponse object which is passed
// in the last argument and filled upon success.
CkHttpResponseW responseOut;
success = http.HttpJson(L"POST",url,json,contentType,responseOut);
if (success == false) {
wprintf(L"%s\n",http.lastErrorText());
return;
}
}