(C++) HTTP DELETE with Body
Demonstrates how to send a DELETE request with a body.
#include <CkHttp.h>
#include <CkHttpResponse.h>
void ChilkatSample(void)
{
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHttp http;
// Use the PText method (or PTextSb) to send a DELETE request with a body.
const char *requestBody = "{ \"abc\": 123 }";
CkHttpResponse *resp = http.PText("DELETE","https://example.com/something",requestBody,"utf-8","application/json",false,false);
if (http.get_LastMethodSuccess() == false) {
std::cout << http.lastErrorText() << "\r\n";
return;
}
std::cout << "Response status: " << resp->get_StatusCode() << "\r\n";
std::cout << "Response body: " << "\r\n";
std::cout << resp->bodyStr() << "\r\n";
delete resp;
}
|