(Chilkat2-Python) Activix CRM Upload a Recording
Upload a recording for an existing communication. For more information, see https://docs.crm.activix.ca/api/resources/communication
import sys
import chilkat2
# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
req = chilkat2.HttpRequest()
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 != True):
print(req.LastErrorText)
sys.exit()
http = chilkat2.Http()
http.AuthToken = "ACCESS_TOKEN"
# resp is a CkHttpResponse
resp = http.SynchronousRequest("crm.activix.ca",443,True,req)
if (http.LastMethodSuccess != True):
print(http.LastErrorText)
sys.exit()
print("Response Status Code: " + str(resp.StatusCode))
jsonResponse = chilkat2.JsonObject()
jsonResponse.Load(resp.BodyStr)
jsonResponse.EmitCompact = False
print(jsonResponse.Emit())
if (resp.StatusCode >= 300):
print("Failed.")
sys.exit()
# Sample output...
# {
# "message": "Recording uploaded successfully."
# }
#
|