(Swift 2) 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.AddFileForUpload("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."
// }
//
}
|