(C) HTTP Post XML
Demonstrates how to POST XML to a website. Note: This example requires Chilkat v11.0.0 or greater.
#include <C_CkHttp.h>
#include <C_CkHttpResponse.h>
void ChilkatSample(void)
{
BOOL success;
HCkHttp http;
const char *url;
const char *xmlBody;
HCkHttpResponse resp;
success = FALSE;
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttp_Create();
// Make sure to replace the URL with something real...
url = "https://example.com/example.asp";
xmlBody = "<test>This is the XML to be sent</test>";
resp = CkHttpResponse_Create();
success = CkHttp_HttpStr(http,"POST",url,xmlBody,"utf-8","application/xml",resp);
if (success == FALSE) {
printf("%s\n",CkHttp_lastErrorText(http));
CkHttp_Dispose(http);
CkHttpResponse_Dispose(resp);
return;
}
// Examine the body of the response.
printf("%s\n",CkHttpResponse_bodyStr(resp));
CkHttp_Dispose(http);
CkHttpResponse_Dispose(resp);
}
|