Sample code for 30+ languages & platforms
C

POST XML to https://apicert.sii.cl/recursos/v1/boleta.electronica.token

See more HTTP Misc Examples

Demonstrates how to send an HTTPS POST XML request to POST XML to https://apicert.sii.cl/recursos/v1/boleta.electronica.token and retrieve the response.

Chilkat C Downloads

C
#include <C_CkHttp.h>
#include <C_CkHttpResponse.h>

void ChilkatSample(void)
    {
    BOOL success;
    HCkHttp http;
    const char *xmlStr;
    const char *urlEndpoint;
    const char *xmlCharset;
    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();

    // XML to send in the body of the HTTPS POST
    xmlStr = "...";

    urlEndpoint = "https://apicert.sii.cl/recursos/v1/boleta.electronica.token";
    xmlCharset = "utf-8";

    resp = CkHttpResponse_Create();
    success = CkHttp_HttpStr(http,"POST",urlEndpoint,xmlStr,"utf-8","application/xml",resp);
    if (success == FALSE) {
        printf("%s\n",CkHttp_lastErrorText(http));
        CkHttp_Dispose(http);
        CkHttpResponse_Dispose(resp);
        return;
    }

    // Get the response status code and body
    printf("response status code = %d\n",CkHttpResponse_getStatusCode(resp));

    // This would be the XML response sent by the server.
    printf("%s\n",CkHttpResponse_bodyStr(resp));


    CkHttp_Dispose(http);
    CkHttpResponse_Dispose(resp);

    }