Unicode C
Unicode C
Send HTTPS POST with XML Body
See more HTTP Examples
Demonstrates how to send an HTTP (or HTTPS) POST where the body of the request is XML.Chilkat Unicode C Downloads
#include <C_CkHttpW.h>
#include <C_CkHttpResponseW.h>
void ChilkatSample(void)
{
BOOL success;
HCkHttpW http;
const wchar_t *strXml;
HCkHttpResponseW resp;
success = FALSE;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
http = CkHttpW_Create();
strXml = L"<TransactionSetup xmlns=\"https://xyz.com\"><Credentials><AccountID>XXX</AccountID></Credentials></TransactionSetup>";
// Maybe you need other headers?
CkHttpW_SetRequestHeader(http,L"Accept",L"application/xml");
resp = CkHttpResponseW_Create();
success = CkHttpW_HttpStr(http,L"POST",L"https://www.somewebsite.com/",strXml,L"utf-8",L"application/xml",resp);
if (success == FALSE) {
wprintf(L"%s\n",CkHttpW_lastErrorText(http));
CkHttpW_Dispose(http);
CkHttpResponseW_Dispose(resp);
return;
}
// Examine the response status code:
wprintf(L"response status code = %d\n",CkHttpResponseW_getStatusCode(resp));
// Examine the response body:
wprintf(L"response body: %s\n",CkHttpResponseW_bodyStr(resp));
CkHttpW_Dispose(http);
CkHttpResponseW_Dispose(resp);
}