Zig
Zig
Activix CRM Upload a Recording
See more Activix CRM Examples
Upload a recording for an existing communication.Chilkat Zig Downloads
const std = @import("std");
const chilkat = @import("chilkat");
pub fn main(init: std.process.Init) !void {
const alloc = init.arena.allocator();
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const req = try chilkat.HttpRequest.init();
defer req.deinit();
req.setHttpVerb("POST");
req.setPath("/api/v2/communications/COMMUNICATION_ID/recording");
req.setContentType("multipart/form-data");
req.addHeader("Accept", "application/json");
const path_to_file_on_disk = "qa_data/CantinaBand3.wav";
req.addFileForUpload("recording", path_to_file_on_disk) catch {
std.debug.print("{s}\n", .{try req.getLastErrorText(alloc)});
return;
};
const http = try chilkat.Http.init();
defer http.deinit();
http.setAuthToken("ACCESS_TOKEN");
const resp = try chilkat.HttpResponse.init();
defer resp.deinit();
http.httpSReq("crm.activix.ca", 443, true, req, resp) catch {
std.debug.print("{s}\n", .{try http.getLastErrorText(alloc)});
return;
};
std.debug.print("Response Status Code: {d}\n", .{resp.getStatusCode()});
const json_response = try chilkat.JsonObject.init();
defer json_response.deinit();
json_response.load(try resp.getBodyStr(alloc)) catch {};
json_response.setEmitCompact(false);
std.debug.print("{s}\n", .{try json_response.emit(alloc)});
if (resp.getStatusCode() >= 300) {
std.debug.print("Failed.\n", .{});
return;
}
// Sample output...
// {
// "message": "Recording uploaded successfully."
// }
//
}