Sample code for 30+ languages & platforms
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

Unicode C++
#include <CkHttpW.h>
#include <CkHttpResponseW.h>

void ChilkatSample(void)
    {
    bool success = false;

    // This example requires the Chilkat API to have been previously unlocked.
    // See Global Unlock Sample for sample code.

    CkHttpW http;

    const wchar_t *strXml = L"<TransactionSetup xmlns=\"https://xyz.com\"><Credentials><AccountID>XXX</AccountID></Credentials></TransactionSetup>";

    // Maybe you need other headers?
    http.SetRequestHeader(L"Accept",L"application/xml");

    CkHttpResponseW resp;
    success = http.HttpStr(L"POST",L"https://www.somewebsite.com/",strXml,L"utf-8",L"application/xml",resp);
    if (success == false) {
        wprintf(L"%s\n",http.lastErrorText());
        return;
    }

    // Examine the response status code:
    wprintf(L"response status code = %d\n",resp.get_StatusCode());

    // Examine the response body:
    wprintf(L"response body: %s\n",resp.bodyStr());
    }