Hi all,
I am trying to update the call handler holiday greetings through the CUPI API.
The environment is unity 8.6, but will soon be migrating to 10.5/6 not sure yet.
I am using the python requests library to perform the request with little success.
The issue that I am having is that no matter the combination of headers etc I have tried I keep getting an error;
- 415 - Unsupported Media Type
Here is my code sample;
import requests
headers = {'Content-type': 'audio/wav', 'Connection': 'keep-alive'}
wave_file = open('/path/to/holiday.wav', 'rb').read()
payload = [('StreamFile', ('holiday.wav', wave_file))]
r = requests.put(url,
auth=('admin', 'p@ss'),
headers=headers,
files=payload,
verify=False
)
Has anyone had any success with updating greetings with python ?
If so can you show me a working code snippet please ?
Thanks in advance.
Brad
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
that error would have less to do with your HTTP headers and such and the WAV file itself - Connection can be fussy about the format which is why all my tools that do anything with greetings/voice names ship with a SoX library to do WAV file conversions - what's the format of your WAV file - I always force pcm:8000,16,1 before uploading.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Thanks @lindborg, (bit lat to reply here, sorry about that) I am certain that is not the issue as I am using a recording that I downloaded for unity and is currently being used. I have in the mean time got this working. I will post a link later on to a python module I am building which has a method for updating greetings
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Here it is:
https://github.com/bobthebutcher/cupi/blob/master/cake.py
I am still working on some methods and documentation. Hopefully it can save someone some cycles.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Comments
0 comments
Please sign in to leave a comment.