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

Walmart v3 Bulk Item Setup

See more Walmart v3 Examples

Updates items in bulk.

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();

    // Implements the following CURL command:

    // curl -X POST \
    //   https://marketplace.walmartapis.com/v3/feeds?feedType=item \
    //   -H 'WM_SVC.NAME: Walmart Marketplace'
    //   -H 'WM_SEC.ACCESS_TOKEN: eyJraWQiOiIzZjVhYTFmNS1hYWE5LTQzM.....'
    //   -H 'WM_QOS.CORRELATION_ID: b3261d2d-028a-4ef7-8602-633c23200af6'
    //   -H 'Content-Type: multipart/form-data'
    //   -H 'Accept: application/xml'
    //   -F feed=@qa_data/walmart/itemFeed.xml

    const req = try chilkat.HttpRequest.init();
    defer req.deinit();
    req.setHttpVerb("POST");
    req.setPath("/v3/feeds?feedType=item");
    req.setContentType("multipart/form-data");
    try req.addFileForUpload2("feed", "qa_data/walmart/itemFeed.xml", "application/xml");

    req.addHeader("WM_QOS.CORRELATION_ID", "b3261d2d-028a-4ef7-8602-633c23200af6");
    req.addHeader("Expect", "100-continue");
    req.addHeader("Content-Type", "multipart/form-data");
    req.addHeader("WM_SEC.ACCESS_TOKEN", "eyJraWQiOiIzZjVhYTFmNS1hYWE5LTQzM.....");
    req.addHeader("Accept", "application/xml");
    req.addHeader("WM_SVC.NAME", "Walmart Marketplace");

    const resp = try chilkat.HttpResponse.init();
    defer resp.deinit();
    http.httpSReq("marketplace.walmartapis.com", 443, true, req, resp) catch {
        std.debug.print("{s}\n", .{try http.getLastErrorText(alloc)});
        return;
    };

    const sb_response_body = try chilkat.StringBuilder.init();
    defer sb_response_body.deinit();
    resp.getBodySb(sb_response_body) catch {};

    const xml_response = try chilkat.Xml.init();
    defer xml_response.deinit();
    xml_response.loadSb(sb_response_body, true) catch {};
    std.debug.print("{s}\n", .{try xml_response.getXml(alloc)});

    // Sample XML response:
    // (Sample code for parsing the XML response is shown below)

    // <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
    // <FeedAcknowledgement xmlns:ns2="http://walmart.com/">
    //     <feedId>E9C04D1FFD99479FBC1341D56DD5F930@AQMB_wA</feedId>
    // </FeedAcknowledgement>

    // Sample code for parsing the XML response...
    // Use the following online tool to generate parsing code from sample XML:
    // Generate Parsing Code from XML

    _ = try xml_response.getAttrValue(alloc, "xmlns:ns2");
    _ = try xml_response.getChildContent(alloc, "feedId");
}