Sample code for 30+ languages & platforms
Dart

Activix CRM Upload a Recording

See more Activix CRM Examples

Upload a recording for an existing communication.

Chilkat Dart Downloads

Dart
import 'package:chilkat/chilkat.dart';

void main() {
  // This example requires the Chilkat API to have been previously unlocked.
  // See Global Unlock Sample for sample code.

  final req = CkHttpRequest();

  req.httpVerb = 'POST';
  req.path = '/api/v2/communications/COMMUNICATION_ID/recording';
  req.contentType = 'multipart/form-data';

  req.addHeader('Accept', 'application/json');

  final pathToFileOnDisk = 'qa_data/CantinaBand3.wav';
  try {
    req.addFileForUpload('recording', pathToFileOnDisk);
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  final http = CkHttp();
  http.authToken = 'ACCESS_TOKEN';

  final resp = CkHttpResponse();
  try {
    http.httpSReq('crm.activix.ca', 443, true, req, resp);
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  print('Response Status Code: ${resp.statusCode}');

  final jsonResponse = CkJsonObject();
  jsonResponse.load(resp.bodyStr);
  jsonResponse.emitCompact = false;
  print(jsonResponse.emit());

  if (resp.statusCode >= 300) {
    print('Failed.');
    return;
  }

  // Sample output...

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