Sample code for 30+ languages & platforms
Ruby

Activix CRM Upload a Recording

See more Activix CRM Examples

Upload a recording for an existing communication.

Chilkat Ruby Downloads

Ruby
require 'chilkat'

success = false

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

req = Chilkat::CkHttpRequest.new()

req.put_HttpVerb("POST")
req.put_Path("/api/v2/communications/COMMUNICATION_ID/recording")
req.put_ContentType("multipart/form-data")

req.AddHeader("Accept","application/json")

pathToFileOnDisk = "qa_data/CantinaBand3.wav"
success = req.AddFileForUpload("recording",pathToFileOnDisk)
if (success == false)
    print req.lastErrorText() + "\n";
    exit
end

http = Chilkat::CkHttp.new()
http.put_AuthToken("ACCESS_TOKEN")

resp = Chilkat::CkHttpResponse.new()
success = http.HttpSReq("crm.activix.ca",443,true,req,resp)
if (success == false)
    print http.lastErrorText() + "\n";
    exit
end

print "Response Status Code: " + resp.get_StatusCode().to_s() + "\n";

jsonResponse = Chilkat::CkJsonObject.new()
jsonResponse.Load(resp.bodyStr())
jsonResponse.put_EmitCompact(false)
print jsonResponse.emit() + "\n";

if (resp.get_StatusCode() >= 300)
    print "Failed." + "\n";
    exit
end

# Sample output...

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