C++
C++
HTTP Post XML
Demonstrates how to POST XML to a website.Chilkat C++ Downloads
#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;
// Make sure to replace the URL with something real...
const char *url = "https://example.com/example.asp";
const char *xmlBody = "<test>This is the XML to be sent</test>";
CkHttpResponse resp;
success = http.HttpStr("POST",url,xmlBody,"utf-8","application/xml",resp);
if (success == false) {
std::cout << http.lastErrorText() << "\r\n";
return;
}
// Examine the body of the response.
std::cout << resp.bodyStr() << "\r\n";
}