Sample code for 30+ languages & platforms
Swift

Activix CRM Upload a Recording

See more Activix CRM Examples

Upload a recording for an existing communication.

Chilkat Swift Downloads

Swift

func chilkatTest() {
    var success: Bool = false

    // 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(name: "Accept", value: "application/json")

    var pathToFileOnDisk: String? = "qa_data/CantinaBand3.wav"
    success = req.addFile(forUpload: "recording", path: pathToFileOnDisk)
    if success == false {
        print("\(req.lastErrorText!)")
        return
    }

    let http = CkoHttp()!
    http.authToken = "ACCESS_TOKEN"

    let resp = CkoHttpResponse()!
    success = http.httpSReq(domain: "crm.activix.ca", port: 443, ssl: true, request: req, response: resp)
    if success == false {
        print("\(http.lastErrorText!)")
        return
    }

    print("Response Status Code: \(resp.statusCode.intValue)")

    let jsonResponse = CkoJsonObject()!
    jsonResponse.load(json: resp.bodyStr)
    jsonResponse.emitCompact = false
    print("\(jsonResponse.emit()!)")

    if resp.statusCode.intValue >= 300 {
        print("Failed.")
        return
    }

    // Sample output...

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

}