Sample code for 30+ languages & platforms
Java

Activix CRM Upload a Recording

See more Activix CRM Examples

Upload a recording for an existing communication.

Chilkat Java Downloads

Java
import com.chilkatsoft.*;

public class ChilkatExample {

  static {
    try {
        System.loadLibrary("chilkat");
    } catch (UnsatisfiedLinkError e) {
      System.err.println("Native code library failed to load.\n" + e);
      System.exit(1);
    }
  }

  public static void main(String argv[])
  {
    boolean success = false;

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

    CkHttpRequest req = new CkHttpRequest();

    req.put_HttpVerb("POST");
    req.put_Path("/api/v2/communications/COMMUNICATION_ID/recording");
    req.put_ContentType("multipart/form-data");

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

    String pathToFileOnDisk = "qa_data/CantinaBand3.wav";
    success = req.AddFileForUpload("recording",pathToFileOnDisk);
    if (success == false) {
        System.out.println(req.lastErrorText());
        return;
        }

    CkHttp http = new CkHttp();
    http.put_AuthToken("ACCESS_TOKEN");

    CkHttpResponse resp = new CkHttpResponse();
    success = http.HttpSReq("crm.activix.ca",443,true,req,resp);
    if (success == false) {
        System.out.println(http.lastErrorText());
        return;
        }

    System.out.println("Response Status Code: " + resp.get_StatusCode());

    CkJsonObject jsonResponse = new CkJsonObject();
    jsonResponse.Load(resp.bodyStr());
    jsonResponse.put_EmitCompact(false);
    System.out.println(jsonResponse.emit());

    if (resp.get_StatusCode() >= 300) {
        System.out.println("Failed.");
        return;
        }

    // Sample output...

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