(Swift 3,4,5...) Activix CRM Upload a Recording
Upload a recording for an existing communication. For more information, see https://docs.crm.activix.ca/api/resources/communication
func chilkatTest() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let req = CkoHttpRequest()!
req.httpVerb = "POST"
req.path = "/api/v2/communications/COMMUNICATION_ID/recording"
req.contentType = "multipart/form-data"
req.addHeader("Accept", value: "application/json")
var pathToFileOnDisk: String? = "qa_data/CantinaBand3.wav"
var success: Bool = req.addFile(forUpload: "recording", path: pathToFileOnDisk)
if success != true {
print("\(req.lastErrorText!)")
return
}
let http = CkoHttp()!
http.authToken = "ACCESS_TOKEN"
var resp: CkoHttpResponse? = http.synchronousRequest("crm.activix.ca", port: 443, ssl: true, req: req)
if http.lastMethodSuccess != true {
print("\(http.lastErrorText!)")
return
}
print("Response Status Code: \(resp!.statusCode.intValue)")
let jsonResponse = CkoJsonObject()!
jsonResponse.load(resp!.bodyStr)
jsonResponse.emitCompact = false
print("\(jsonResponse.emit()!)")
if resp!.statusCode.intValue >= 300 {
print("Failed.")
resp = nil
return
}
resp = nil
// Sample output...
// {
// "message": "Recording uploaded successfully."
// }
//
}
|