cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
1029
Views
0
Helpful
2
Replies

CUPI: Uploading Call Handler Greeting returns 415 Unsupported Media

masloan
Cisco Employee
Cisco Employee

Hello,

 

I'm working with the Unity Connection CUPI API to manage Call Handler greetings. I've been using the documentation here and have tried both the new "one-step" and older "multi-step" process to upload a new greeting but I only get a response of 415 Unsupported Media Type. I realize the file format needs to be exact so I've been using a file that I downloaded from Unity Connection via the Call Handler API. Anyone here have some experience with this API and could point me in the right direction?

Thanks,

Marty

1 Accepted Solution

Accepted Solutions

lindborg
Cisco Employee
Cisco Employee

The first step is to see what you're sending - the best way to do this is to use Fiddler2 - if you're not already using it, you'll want to, it's fabulous - you can download it for free from here: https://www.telerik.com/download/fiddler

 

so once monitoring HTTP traffic outbound with that you should see the greeting upload PUT call that should look roughly like this:

PUT https://10.93.132.83:8443/vmrest/handlers/callhandlers/56bc0444-bc13-4355-a774-e203521b42ae/greetings/Standard/greetingstreamfiles/1033/audio
Content-Type: audio/wav
Authorization: Basic **************************
Cookie: JSESSIONIDSSO=D1EC1579C234EE68A59334459A377E31; Path=/; Secure; HttpOnly;JSESSIONID=D20E3B1C4B1DB8A852BE8AC05D782EE0; Path=/vmrest; Secure; HttpOnly;REQUEST_TOKEN_KEY=-8332258646152487489; Path=/; Secure; HttpOnly;
Host: 10.93.132.83:8443
Content-Length: 700439
Connection: Close

RIFF 
 WAVEfmt      @   >    data 
 C   . P ~       c }     Pl     hp[-      G      i      a Y [   
...

obviously the WAV file binary goes on and on there, it's cut off here for readability.  The wav file content is a byte array representation of the wav - assuming the wav you're using is one already hosted on Connection the format should be fine, I suspect what you're appending or how you're sending the attachment is not being parsed out by Connection.  In .NET you'd grab the file and convert it into a byte array and append it to the file like this:

streamTemp = File.Open(pLocalWavFilePath, FileMode.Open);
                BinaryReader binReader = new BinaryReader(streamTemp);
                buffer = new byte[Convert.ToInt32(binReader.BaseStream.Length) + 1];
                binReader.Read(buffer, 0, buffer.Length);

at this point the buffer byte array contains everything you need to append to the PUT command and you're good to go.

 

As a side note, last week I was working with a site needing to upload a lot of pre recorded greetings for users' standard greetings - I started working on a simple command line tool with them you can use for testing - you can look at what the Fiddler2 output looks like for my tool uploading a user's greeting vs. what yours looks like and see if you can spot the problem.  You can get the bulk greeting uploader CLI from the temporary download page here: http://www.ciscounitytools.com/Temp/

 

You'd just create a test user with an alias like "testuser" and then copy the greeting you're using into a folder and name it "testuser.wav" - calling the cli tool with the server name, login and password for an admin and a path to that greeting folder will cause it to upload that wav file as the us English standard greeting for that user - if it works you know the format is good and you can watch in Fiddler to see the upload format.

 

Also side note - I do intend to expand the greeting uploader to handle other greetings (alternate, busy etc...), and both users and call handlers - although handlers are a little tricky since extensions are optional and they don't have unique identifiers like alias to use as a search mechanism... 

View solution in original post

2 Replies 2

lindborg
Cisco Employee
Cisco Employee

The first step is to see what you're sending - the best way to do this is to use Fiddler2 - if you're not already using it, you'll want to, it's fabulous - you can download it for free from here: https://www.telerik.com/download/fiddler

 

so once monitoring HTTP traffic outbound with that you should see the greeting upload PUT call that should look roughly like this:

PUT https://10.93.132.83:8443/vmrest/handlers/callhandlers/56bc0444-bc13-4355-a774-e203521b42ae/greetings/Standard/greetingstreamfiles/1033/audio
Content-Type: audio/wav
Authorization: Basic **************************
Cookie: JSESSIONIDSSO=D1EC1579C234EE68A59334459A377E31; Path=/; Secure; HttpOnly;JSESSIONID=D20E3B1C4B1DB8A852BE8AC05D782EE0; Path=/vmrest; Secure; HttpOnly;REQUEST_TOKEN_KEY=-8332258646152487489; Path=/; Secure; HttpOnly;
Host: 10.93.132.83:8443
Content-Length: 700439
Connection: Close

RIFF 
 WAVEfmt      @   >    data 
 C   . P ~       c }     Pl     hp[-      G      i      a Y [   
...

obviously the WAV file binary goes on and on there, it's cut off here for readability.  The wav file content is a byte array representation of the wav - assuming the wav you're using is one already hosted on Connection the format should be fine, I suspect what you're appending or how you're sending the attachment is not being parsed out by Connection.  In .NET you'd grab the file and convert it into a byte array and append it to the file like this:

streamTemp = File.Open(pLocalWavFilePath, FileMode.Open);
                BinaryReader binReader = new BinaryReader(streamTemp);
                buffer = new byte[Convert.ToInt32(binReader.BaseStream.Length) + 1];
                binReader.Read(buffer, 0, buffer.Length);

at this point the buffer byte array contains everything you need to append to the PUT command and you're good to go.

 

As a side note, last week I was working with a site needing to upload a lot of pre recorded greetings for users' standard greetings - I started working on a simple command line tool with them you can use for testing - you can look at what the Fiddler2 output looks like for my tool uploading a user's greeting vs. what yours looks like and see if you can spot the problem.  You can get the bulk greeting uploader CLI from the temporary download page here: http://www.ciscounitytools.com/Temp/

 

You'd just create a test user with an alias like "testuser" and then copy the greeting you're using into a folder and name it "testuser.wav" - calling the cli tool with the server name, login and password for an admin and a path to that greeting folder will cause it to upload that wav file as the us English standard greeting for that user - if it works you know the format is good and you can watch in Fiddler to see the upload format.

 

Also side note - I do intend to expand the greeting uploader to handle other greetings (alternate, busy etc...), and both users and call handlers - although handlers are a little tricky since extensions are optional and they don't have unique identifiers like alias to use as a search mechanism... 

Hi Jeff,

 

Thanks!  After reading your post it hit me that I not only need to be mindful of the file format but also how I'm sending/attaching the wav file.  I was using the wrong request body type in Postman.  When I switched from form-data to binary it worked.  I also tested with my actual code/http client and it worked there as well.

 

Also, thanks for the tip on Fiddler and the new bulk greeting uploader.  I have that downloaded and started configuring it.  It'll def come in handy!

 

Marty