Sample code for 30+ languages & platforms
Rust

Activix CRM Upload a Recording

See more Activix CRM Examples

Upload a recording for an existing communication.

Chilkat Rust Downloads

Rust

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

let req = chilkat::HttpRequest::new();

req.set_http_verb("POST");
req.set_path("/api/v2/communications/COMMUNICATION_ID/recording");
req.set_content_type("multipart/form-data");

req.add_header("Accept", "application/json");

let path_to_file_on_disk = "qa_data/CantinaBand3.wav".to_string();
if req.add_file_for_upload("recording", &path_to_file_on_disk).is_err() {
    println!("{}", req.last_error_text());
    return;
}

let http = chilkat::Http::new();
http.set_auth_token("ACCESS_TOKEN");

let resp = chilkat::HttpResponse::new();
if http.http_s_req("crm.activix.ca", 443, true, &req, &resp).is_err() {
    println!("{}", http.last_error_text());
    return;
}

println!("Response Status Code: {}", resp.status_code());

let json_response = chilkat::JsonObject::new();
let _ = json_response.load(&resp.body_str());
json_response.set_emit_compact(false);
println!("{}", json_response.emit().unwrap_or_default());

if resp.status_code() >= 300 {
    println!("Failed.");
    return;
}

// Sample output...

// {
//   "message": "Recording uploaded successfully."
// }
//