Lua
Lua
Activix CRM Upload a Recording
See more Activix CRM Examples
Upload a recording for an existing communication.Chilkat Lua Downloads
local chilkat = require("chilkat")
-- This example requires the Chilkat API to have been previously unlocked.
-- See Global Unlock Sample for sample code.
local req = chilkat.HttpRequest.new()
req.http_verb = "POST"
req.path = "/api/v2/communications/COMMUNICATION_ID/recording"
req.content_type = "multipart/form-data"
req:add_header("Accept", "application/json")
local pathToFileOnDisk = "qa_data/CantinaBand3.wav"
local success = req:add_file_for_upload("recording", pathToFileOnDisk)
if not success then
print(req.last_error_text)
return
end
local http = chilkat.Http.new()
http.auth_token = "ACCESS_TOKEN"
local resp = chilkat.HttpResponse.new()
success = http:http_sreq("crm.activix.ca", 443, true, req, resp)
if not success then
print(http.last_error_text)
return
end
print("Response Status Code: " .. resp.status_code)
local jsonResponse = chilkat.JsonObject.new()
jsonResponse:load(resp.body_str)
jsonResponse.emit_compact = false
print(jsonResponse:emit())
if resp.status_code >= 300 then
print("Failed.")
return
end
-- Sample output...
-- {
-- "message": "Recording uploaded successfully."
-- }
--