(C++) HTTP DELETE with Body
Demonstrates how to send a DELETE request with a body. Note: This example requires Chilkat v11.0.0 or greater.
#include <CkHttp.h>
#include <CkHttpResponse.h>
void ChilkatSample(void)
{
bool success = false;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkHttp http;
// Use the HttpStr method (or HttpSb) to send a DELETE request with a body.
const char *requestBody = "{ \"abc\": 123 }";
CkHttpResponse resp;
success = http.HttpStr("DELETE","https://example.com/something",requestBody,"utf-8","application/json",resp);
if (success == 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";
}
|