(Objective-C) Activix CRM Upload a Recording
Upload a recording for an existing communication. For more information, see https://docs.crm.activix.ca/api/resources/communication
#import <CkoHttpRequest.h>
#import <NSString.h>
#import <CkoHttp.h>
#import <CkoHttpResponse.h>
#import <CkoJsonObject.h>
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkoHttpRequest *req = [[CkoHttpRequest alloc] init];
req.HttpVerb = @"POST";
req.Path = @"/api/v2/communications/COMMUNICATION_ID/recording";
req.ContentType = @"multipart/form-data";
[req AddHeader: @"Accept" value: @"application/json"];
NSString *pathToFileOnDisk = @"qa_data/CantinaBand3.wav";
BOOL success = [req AddFileForUpload: @"recording" path: pathToFileOnDisk];
if (success != YES) {
NSLog(@"%@",req.LastErrorText);
return;
}
CkoHttp *http = [[CkoHttp alloc] init];
http.AuthToken = @"ACCESS_TOKEN";
CkoHttpResponse *resp = [http SynchronousRequest: @"crm.activix.ca" port: [NSNumber numberWithInt: 443] ssl: YES req: req];
if (http.LastMethodSuccess != YES) {
NSLog(@"%@",http.LastErrorText);
return;
}
NSLog(@"%@%d",@"Response Status Code: ",[resp.StatusCode intValue]);
CkoJsonObject *jsonResponse = [[CkoJsonObject alloc] init];
[jsonResponse Load: resp.BodyStr];
jsonResponse.EmitCompact = NO;
NSLog(@"%@",[jsonResponse Emit]);
if ([resp.StatusCode intValue] >= 300) {
NSLog(@"%@",@"Failed.");
return;
}
// Sample output...
// {
// "message": "Recording uploaded successfully."
// }
//
|