Objective-C
Objective-C
Activix CRM Upload a Recording
See more Activix CRM Examples
Upload a recording for an existing communication.Chilkat Objective-C Downloads
#import <CkoHttpRequest.h>
#import <NSString.h>
#import <CkoHttp.h>
#import <CkoHttpResponse.h>
#import <CkoJsonObject.h>
BOOL success = NO;
// 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";
success = [req AddFileForUpload: @"recording" path: pathToFileOnDisk];
if (success == NO) {
NSLog(@"%@",req.LastErrorText);
return;
}
CkoHttp *http = [[CkoHttp alloc] init];
http.AuthToken = @"ACCESS_TOKEN";
CkoHttpResponse *resp = [[CkoHttpResponse alloc] init];
success = [http HttpSReq: @"crm.activix.ca" port: [NSNumber numberWithInt: 443] ssl: YES request: req response: resp];
if (success == NO) {
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."
// }
//