C
C
Transition from Http.QuickRequestParams to Http.HttpParams
Provides instructions for replacing deprecated QuickRequestParams method calls with HttpParams.Chilkat C Downloads
#include <C_CkHttp.h>
#include <C_CkJsonObject.h>
#include <C_CkHttpResponse.h>
void ChilkatSample(void)
{
BOOL success;
HCkHttp http;
const char *verb;
const char *url;
HCkJsonObject json;
HCkHttpResponse responseObj;
HCkHttpResponse responseOut;
success = FALSE;
http = CkHttp_Create();
verb = "GET";
url = "https://example.com/";
json = CkJsonObject_Create();
CkJsonObject_UpdateInt(json,"param1",100);
CkJsonObject_UpdateString(json,"param2","test");
// ------------------------------------------------------------------------
// The QuickRequestParams method is deprecated:
responseObj = CkHttp_QuickRequestParams(http,verb,url,json);
if (CkHttp_getLastMethodSuccess(http) == FALSE) {
printf("%s\n",CkHttp_lastErrorText(http));
CkHttp_Dispose(http);
CkJsonObject_Dispose(json);
return;
}
// ...
// ...
CkHttpResponse_Dispose(responseObj);
// ------------------------------------------------------------------------
// Do the equivalent using HttpParams.
// Your application creates a new, empty HttpResponse object which is passed
// in the last argument and filled upon success.
responseOut = CkHttpResponse_Create();
success = CkHttp_HttpParams(http,verb,url,json,responseOut);
if (success == FALSE) {
printf("%s\n",CkHttp_lastErrorText(http));
CkHttp_Dispose(http);
CkJsonObject_Dispose(json);
CkHttpResponse_Dispose(responseOut);
return;
}
CkHttp_Dispose(http);
CkJsonObject_Dispose(json);
CkHttpResponse_Dispose(responseOut);
}