Java
Chilkat2 Java
Activix CRM Upload a Recording
See more Activix CRM Examples
Upload a recording for an existing communication.Chilkat Java Downloads
import com.chilkatsoft.chilkat2.ChilkatException;
import com.chilkatsoft.chilkat2.Http;
import com.chilkatsoft.chilkat2.HttpRequest;
import com.chilkatsoft.chilkat2.HttpResponse;
import com.chilkatsoft.chilkat2.JsonObject;
public class ChilkatExample {
public static void main(String[] args) {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
HttpRequest req = new HttpRequest();
req.setHttpVerb("POST");
req.setPath("/api/v2/communications/COMMUNICATION_ID/recording");
req.setContentType("multipart/form-data");
req.addHeader("Accept", "application/json");
String pathToFileOnDisk = "qa_data/CantinaBand3.wav";
try {
req.addFileForUpload("recording", pathToFileOnDisk);
} catch (ChilkatException e) {
System.out.println(e.getLastErrorText());
return;
}
Http http = new Http();
http.setAuthToken("ACCESS_TOKEN");
HttpResponse resp = new HttpResponse();
try {
http.httpSReq("crm.activix.ca", 443, true, req, resp);
} catch (ChilkatException e) {
System.out.println(e.getLastErrorText());
return;
}
System.out.println("Response Status Code: " + resp.getStatusCode());
JsonObject jsonResponse = new JsonObject();
jsonResponse.load(resp.getBodyStr());
jsonResponse.setEmitCompact(false);
System.out.println(jsonResponse.emit());
if (resp.getStatusCode() >= 300) {
System.out.println("Failed.");
return;
}
// Sample output...
// {
// "message": "Recording uploaded successfully."
// }
//
}
}