(Unicode C) HTTP DELETE with Body
Demonstrates how to send a DELETE request with a body.
#include <C_CkHttpW.h>
#include <C_CkHttpResponseW.h>
void ChilkatSample(void)
{
HCkHttpW http;
const wchar_t *requestBody;
HCkHttpResponseW resp;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_Create();
// Use the PText method (or PTextSb) to send a DELETE request with a body.
requestBody = L"{ \"abc\": 123 }";
resp = CkHttpW_PText(http,L"DELETE",L"https://example.com/something",requestBody,L"utf-8",L"application/json",FALSE,FALSE);
if (CkHttpW_getLastMethodSuccess(http) == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
return;
}
wprintf(L"Response status: %d\n",CkHttpResponseW_getStatusCode(resp));
wprintf(L"Response body: \n");
wprintf(L"%s\n",CkHttpResponseW_bodyStr(resp));
CkHttpResponseW_Dispose(resp);
CkHttpW_Dispose(http);
}
|