CUC Forums

« Back to CUMI Questions

How to access messages (.WAV file) from CUMI

Combination View Flat View Tree View
Threads [ Previous | Next ]
Hi ,
I am trying to use CUMI REST API  to get the actual message voice file/Stream from inbox. I am getting the following error.

I am First  getting the messages using the following url
https://1.1.1.1:8443/vmrest/mailbox/folders/inbox/messages?pagenumber=1&rowsperpage=10&userobjectid=9b7339e7-2c1c-4fe0-9f3a-89a891230655
Here is the response
 
- <Messages>
 
- <Message>
  <Subject>Message from test Test (333339990)</Subject>
 
  <Read>false</Read>

  <Dispatch>false</Dispatch>

  <Secure>false</Secure>

  <Priority>Normal</Priority>

  <Sensitivity>Normal</Sensitivity>

  <URI>/vmrest/messages/0:f67dc8e3-64e1-4475-a3e3-ac024b3f6b5d</URI>
 
  <MsgId>0:f67dc8e3-64e1-4475-a3e3-ac024b3f6b5d</MsgId>
 
- <From>
 

  <DisplayName>test</DisplayName>
 
  <SmtpAddress>unityconnection@armfgasunity1</SmtpAddress>
 
  </From>
 
- <CallerId>
 

  <CallerNumber>2223339990</CallerNumber>
 
  <CallerName>Test</CallerName>
  </CallerId>
 
  <ArrivalTime>1314728967000</ArrivalTime>
 
  <Size>38762</Size>

  <Duration>3470</Duration>

  <FromSub>false</FromSub>

  <MsgType>Voice</MsgType>
  </Message>
 
- <Message>
 

  <Subject>Message from Test Test (3333339990)</Subject>
 
  <Read>false</Read>

  <Dispatch>false</Dispatch>

  <Secure>false</Secure>

  <Priority>Normal</Priority>

  <Sensitivity>Normal</Sensitivity>

  <URI>/vmrest/messages/0:5271193c-4199-4d53-83a3-7863cb1f3c5d</URI>
 
  <MsgId>0:5271193c-4199-4d53-83a3-7863cb1f3c5d</MsgId>
 
- <From>
 

  <DisplayName>Test</DisplayName>
 
  <SmtpAddress>unityconnection@armfgasunity1</SmtpAddress>
 
  </From>
 
- <CallerId>
 

  <CallerNumber>4443339990</CallerNumber>
 
  <CallerName>Test</CallerName>
  </CallerId>
 
  <ArrivalTime>1314725691000</ArrivalTime>
 
  <Size>41170</Size>

  <Duration>3690</Duration>

  <FromSub>false</FromSub>

  <MsgType>Voice</MsgType>
  </Message>
 
  </Messages>

once i get the message list, i am trying to retreive audio message (wave file or rtsp stream) using the following URL,
https://1.1.1.1:8443/vmrest/messages/0:5271193c-4199-4d53-83a3-7863cb1f3c5d
I am getting "bad request" response.

I cant seem to find docuementation to extract WAV file using CUMI.  Has anyone able to get the audio file from above message using the REST API.

Thanks
kesava

I am having the same problem. We are switching our code to use the new REST API's, but if we can't get the attachment, we will have to stop and revert back. This will cause major issues.


Thanks,

Will

Make sure your are using HTTP method GET, generally only a POST or a PUT will cause a 400 (bad request error).  The 400 error will also have content that should specify what caused the error, check to see what the content of the response is,
 
-Dave

David,

We are using Get. What is the correct URL to use? I am using

https://devucn85.devucn85.local:8443/vmrest/messages/0:00b7fa58-af98-4e95-9e87-054b52f4fbbb/attachments/1


/vmrest/messages/0:00b7fa58-af98-4e95-9e87-054b52f4fbbb/attachments/1 is the URI I get back from the attachment XML when I get the message details.


Here is my method.


MemoryStream memoryStream = new MemoryStream();
WebRequest webRequest = WebRequest.Create(string.Format("https://{0}:{1}{2}", UCNServer, RestPort, restURL));

var userPassword = string.Format("{0}:{1}", Username, Password);
var encDataByte = Encoding.UTF8.GetBytes(userPassword);
var encodedData = Convert.ToBase64String(encDataByte);
webRequest.Headers.Add("Authorization", "Basic " + encodedData);
webRequest.Method = "Get";
byte[] fileBytes = null;
byte[] buffer = new byte[4096];
WebResponse webResponse = webRequest.GetResponse();
try
{
Stream stream = webResponse.GetResponseStream();

int chunkSize = 0;
do
{
chunkSize = stream.Read(buffer, 0, buffer.Length);
memoryStream.Write(buffer, 0, chunkSize);
} while (chunkSize != 0);
fileBytes = memoryStream.ToArray();
}
catch (Exception ex)
{
Console.Write(ex.Message);
}
return memoryStream;

Ok, so I think your problem is different than the one reported by the initial post to this thread.  The original post has a problem with a 400 error when trying to get individual message details.  It sounds like you are able to retrieve the individual message details but are getting an error when trying to retrieve the attachments.  What repsonse are you getting using the message attachment URI?
 
-Dave

David,

I am getting the same error, Bad Request

What is the content of the response?

Hi david:

I have exactly same issue as Will, except that he is trying from the code and i am trying from POSTER in Firefox.

1. I am successful in getting messages for the mail boxes (XML is as shown in my original post);
2. Once i know i have new messages, i want to be able to play them using attachment URI and thats where we are seeing an error.

here is the error msg for this request:

REST CALL:
https://1.1.1.1:8443/vmrest/messages/0:5271193c-4199-4d53-83a3-7863cb1f3c5d

Output:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?><ErrorDetails><errors><code>INVALID_PARAMETER</code><message>unable to create CML session for user: id=1da20739-b1c7-4641-8eb9-af18b3276789, message=CMLException: 0x46401 code in file CsCmlJni/CsCmlJniSessionFactory.cpp at line 116.</message></errors></ErrorDetails>

Any suggestions.

thanks

That error almost always means that the user you are using to authenticate does not have a mailbox (i.e. is an administrative user).  You need to either sign in as a user with a mailbox or make sure you pass the target userobjectid as a request parameter.  The target user must have a mailbox.
 
-Dave

Thanks Dave.

It is working now ,
I have question what is the attachmentfileter value.
When i try this ,I am getting UNRECOGNIZED_ATTACHMENT_TYPE

Request
https://1.1.1.1:8443/vmrest/messages/0:5271193c-4199-4d53-83a3-7863cb1f3c5d/?userobjectid=9b7339e7-2c1c-4fe0-9f3a-89a891230655&attachmentfilter=Audio

Response
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><ErrorDetails><errors><code>UNRECOGNIZED_ATTACHMENT_TYPE</code><message>attachment type not recognized: type=Audio, filter=Audio</message></errors></ErrorDetails>


I removed the attachmentfilter and did try .It is working.
https://1.1.1.1:8443/vmrest/messages/0:5271193c-4199-4d53-83a3-7863cb1f3c5d/?userobjectid=9b7339e7-2c1c-4fe0-9f3a-89a891230655

I am also able to get Audio file .
https://1.1.1.1:8443/vmrest/messages/0:5271193c-4199-4d53-83a3-7863cb1f3c5d/attachments/0/?userobjectid=9b7339e7-2c1c-4fe0-9f3a-89a891230655&filename=voicemessage.wav

Thank you very much for the quick response.

Thanks
kesava

The attachment filter allows clients to block attachments they don't know how to present.  The Connection database supports the following attachment types:
 
audio/wav 
image/TIFF 
text/plain 
other 
report
 
Most of the time for most applications audio/wav is the filter used to separate out the voice messages.
 
-Dave
 

After the user has listened to the retrieved message (.WAV file) is there a way to change the ¿Read¿ message state to ¿TRUE¿

Before the user listens to the message:
<Message>
<Subject>Message from test Test (333339990)</Subject>
<Read>false</Read>

After the user listens to the message:
<Message>
<Subject>Message from test Test (333339990)</Subject>
<Read>true</Read>

Thanks.

Use Put Method for REST call
e.g URL
https://xxxxxxxxx:444/vmrest/messages/0:5c530874-a7c9-4f4e-89cb-9216cdaea475/?userobjectid=9b7339e7-2c1c-4fe0-9f3a-89a891230655
Body of the message
<Message><Read>true</Read></Message>
 
Thanks
kesava