Sample code for 30+ languages & platforms
Zig Requires Chilkat v11.0.0+

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 Zig Downloads

Zig
const std = @import("std");
const chilkat = @import("chilkat");

pub fn main(init: std.process.Init) !void {
    const alloc = init.arena.allocator();

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

    const http = try chilkat.Http.init();
    defer http.deinit();

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

    const url_endpoint = "https://apicert.sii.cl/recursos/v1/boleta.electronica.token";

    const resp = try chilkat.HttpResponse.init();
    defer resp.deinit();
    http.httpStr("POST", url_endpoint, xml_str, "utf-8", "application/xml", resp) catch {
        std.debug.print("{s}\n", .{try http.getLastErrorText(alloc)});
        return;
    };

    // Get the response status code and body
    std.debug.print("response status code = {d}\n", .{resp.getStatusCode()});

    // This would be the XML response sent by the server.
    std.debug.print("{s}\n", .{try resp.getBodyStr(alloc)});
}