Sample code for 30+ languages & platforms
Delphi ActiveX

Activix CRM Upload a Recording

See more Activix CRM Examples

Upload a recording for an existing communication.

Chilkat Delphi ActiveX Downloads

Delphi ActiveX
uses
    Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
    Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Chilkat_TLB;

...

procedure TForm1.Button1Click(Sender: TObject);
var
success: Integer;
req: TChilkatHttpRequest;
pathToFileOnDisk: WideString;
http: TChilkatHttp;
resp: TChilkatHttpResponse;
jsonResponse: TChilkatJsonObject;

begin
success := 0;

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

req := TChilkatHttpRequest.Create(Self);

req.HttpVerb := 'POST';
req.Path := '/api/v2/communications/COMMUNICATION_ID/recording';
req.ContentType := 'multipart/form-data';

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

pathToFileOnDisk := 'qa_data/CantinaBand3.wav';
success := req.AddFileForUpload('recording',pathToFileOnDisk);
if (success = 0) then
  begin
    Memo1.Lines.Add(req.LastErrorText);
    Exit;
  end;

http := TChilkatHttp.Create(Self);
http.AuthToken := 'ACCESS_TOKEN';

resp := TChilkatHttpResponse.Create(Self);
success := http.HttpSReq('crm.activix.ca',443,1,req.ControlInterface,resp.ControlInterface);
if (success = 0) then
  begin
    Memo1.Lines.Add(http.LastErrorText);
    Exit;
  end;

Memo1.Lines.Add('Response Status Code: ' + IntToStr(resp.StatusCode));

jsonResponse := TChilkatJsonObject.Create(Self);
jsonResponse.Load(resp.BodyStr);
jsonResponse.EmitCompact := 0;
Memo1.Lines.Add(jsonResponse.Emit());

if (resp.StatusCode >= 300) then
  begin
    Memo1.Lines.Add('Failed.');
    Exit;
  end;

// Sample output...

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