This document was generated from CDN thread Created by: Kesava Murukuti on 13-09-2011 01:33:33 PM 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 urlhttps://1.1.1.1:8443/vmrest/mailbox/folders/inbox/messages?pagenumber=1&rowsperpage=10&userobjectid=9b7339e7-2c1c-4fe0-9f3a-89a891230655Here 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-7863cb1f3c5dI 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.ThankskesavaSubject: RE: How to access messages (.WAV file) from CUMI Replied by: Will Ashley on 14-09-2011 09:45:10 AMI 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,WillSubject: RE: How to access messages (.WAV file) from CUMI Replied by: Will Ashley on 14-09-2011 09:59:52 AMDavid,We are using Get. What is the correct URL to use? I am usinghttps://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;Subject: RE: How to access messages (.WAV file) from CUMI Replied by: Will Ashley on 14-09-2011 11:12:03 AMDavid,I am getting the same error, Bad RequestSubject: RE: How to access messages (.WAV file) from CUMI Replied by: David Wanagel on 14-09-2011 09:55:03 AMMake 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, -DaveSubject: RE: How to access messages (.WAV file) from CUMI Replied by: David Wanagel on 14-09-2011 11:08:44 AMOk, 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? -DaveSubject: RE: How to access messages (.WAV file) from CUMI Replied by: David Wanagel on 14-09-2011 11:13:29 AMWhat is the content of the response?Subject: RE: How to access messages (.WAV file) from CUMI Replied by: Kesava Murukuti on 14-09-2011 03:27:33 PMHi 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-7863cb1f3c5dOutput:<?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.thanksSubject: RE: How to access messages (.WAV file) from CUMI Replied by: David Wanagel on 14-09-2011 04:33:32 PMThat 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. -DaveSubject: RE: How to access messages (.WAV file) from CUMI Replied by: Kesava Murukuti on 15-09-2011 01:39:17 AMThanks Dave.It is working now ,I have question what is the attachmentfileter value.When i try this ,I am getting UNRECOGNIZED_ATTACHMENT_TYPERequesthttps://1.1.1.1:8443/vmrest/messages/0:5271193c-4199-4d53-83a3-7863cb1f3c5d/?userobjectid=9b7339e7-2c1c-4fe0-9f3a-89a891230655&attachmentfilter=AudioResponse <?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-89a891230655I 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.wavThank you very much for the quick response.ThankskesavaSubject: RE: How to access messages (.WAV file) from CUMI Replied by: David Wanagel on 15-09-2011 05:58:01 AMThe 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 Subject: RE: How to access messages (.WAV file) from CUMI Replied by: Jamie O'Leary on 07-10-2011 05:54:01 AMAfter 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.Subject: RE: How to access messages (.WAV file) from CUMI Replied by: Kesava Murukuti on 22-10-2011 11:15:02 PMUse Put Method for REST calle.g URLhttps://xxxxxxxxx:444/vmrest/messages/0:5c530874-a7c9-4f4e-89cb-9216cdaea475/?userobjectid=9b7339e7-2c1c-4fe0-9f3a-89a891230655Body of the message<Message><Read>true</Read></Message> Thankskesava Subject: RE: How to access messages (.WAV file) from CUMI Replied by: Snehal_Vasant_Sakpal (simulated) on 13-07-2013 02:38:31 AMHi all,I am new to using this CUMI API as well as with GET requests and allI am trying to write a code via which i want each user to be able to see his voicemail messages and even play voicemailsi know nothing as to how to go for this. I have googled a lott and could just find the get request for e.g.1GET /vmrest/mailbox/folders/inbox/messages
.But to write this from the code behind in csharp or .net i dont know I tried using the following code from one of the postsMemoryStream 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; But over here i just know my unity server name and porti dont know the REST URL
I need to finish this module in a weekCan anyone please help me with the code. its reallly urgentThanksSubject: RE: New Message from Snehal_Vasant_Sakpal (simulated) in Unity Connection(C Replied by: Loyd Vest on 15-07-2013 08:51:34 AMSnehal,You have to first get the User Object ID for each user. Then you can retrieve the messages for that user’s inbox.For example, you have to do a get for either all the users on the system, and then loop through those users to retrieve the messages. Using the URL:GET /vmrest/usersOr if you have the user’s alias you can build your URL as so with the alias starting with “doc”:GET /vmrest/users?query=%28alias%20startswith%20docHere’s an example of the XML that is returned:<User><URI>/vmrest/users/0d3fd550-6c76-4492-b0f4-aa835da300f7</URI><ObjectId>0d3fd550-6c76-4492-b0f4-aa835da300f7</ObjectId><FirstName>Store 00001</FirstName><LastName>Store 00001</LastName><Alias>doc00001</Alias><City/><Department/><EmployeeId/><DisplayName>Store 00001</DisplayName><TimeZone>0</TimeZone><CreationTime>2012-10-17T14:46:39Z</CreationTime><CosObjectId>e87621b3-97b9-4faf-9ed7-b24e5b4702f7</CosObjectId><CosURI>/vmrest/coses/e87621b3-97b9-4faf-9ed7-b24e5b4702f7</CosURI><Language>0</Language><LocationObjectId>bae5a010-c393-40e8-9ba5-b9221a83867b</LocationObjectId><LocationURI>/vmrest/locations/connectionlocations/bae5a010-c393-40e8-9ba5-b9221a83867b</LocationURI><ListInDirectory>true</ListInDirectory><IsVmEnrolled>false</IsVmEnrolled><MediaSwitchObjectId>cf26c850-ad74-4d9f-990a-da90d72e8212</MediaSwitchObjectId><PhoneSystemURI>/vmrest/phonesystems/cf26c850-ad74-4d9f-990a-da90d72e8212</PhoneSystemURI><CallHandlerObjectId>f9098374-93f5-440f-976e-c97ea1768df8</CallHandlerObjectId><CallhandlerURI>/vmrest/handlers/callhandlers/f9098374-93f5-440f-976e-c97ea1768df8</CallhandlerURI><DtmfAccessId>42001</DtmfAccessId><VoiceNameRequired>false</VoiceNameRequired><PartitionObjectId>900c3ba2-2216-4ef7-8210-4a35d8c6566c</PartitionObjectId><PartitionURI>/vmrest/partitions/900c3ba2-2216-4ef7-8210-4a35d8c6566c</PartitionURI><MwisURI>/vmrest/users/0d3fd550-6c76-4492-b0f4-aa835da300f7/mwis</MwisURI><NotificationDevicesURI>/vmrest/users/0d3fd550-6c76-4492-b0f4-aa835da300f7/notificationdevices</NotificationDevicesURI><MessageHandlersURI>/vmrest/users/0d3fd550-6c76-4492-b0f4-aa835da300f7/messagehandlers</MessageHandlersURI><ExternalServiceAccountsURI>/vmrest/users/0d3fd550-6c76-4492-b0f4-aa835da300f7/externalserviceaccounts</ExternalServiceAccountsURI><AlternateExtensionsURI>/vmrest/users/0d3fd550-6c76-4492-b0f4-aa835da300f7/alternateextensions</AlternateExtensionsURI><PrivateListsURI>/vmrest/users/0d3fd550-6c76-4492-b0f4-aa835da300f7/privatelists</PrivateListsURI><SmtpProxyAddressesURI>/vmrest/smtpproxyaddresses?query=(ObjectGlobalUserObjectId%20is%200d3fd550-6c76-4492-b0f4-aa835da300f7)</SmtpProxyAddressesURI><AlternateNamesURI>/vmrest/alternatenames?query=(GlobalUserObjectId%20is%200d3fd550-6c76-4492-b0f4-aa835da300f7)</AlternateNamesURI></User>One of the fields in the XML that is returned is the User ObjectID, highlighted above. Once you have the User Object ID you can then do a Get for the messages in that user’s inbox.GET /vmrest/mailbox/folders/inbox/messages?userobjectid=0d3fd550-6c76-4492-b0f4-aa835da300f7Hope this helps.[http://www.cisco.com/swa/i/logo.gif]Loyd D. VestSR. Custom Software EngineerAdvanced Services/Customer Collaboration Service Line/Custom Engineering Servicesloydv@cisco.com<mailto:loydv@cisco.com>Phone :412-237-6214Mobile :304-646-0563This e-mail may contain confidential and privileged material for the sole use of the intended recipient. Any review, use, distribution or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive for the recipient), please contact the sender by reply e-mail and delete all copies of this message.From: Cisco Developer Community Forums [mailto:cdicuser@developer.cisco.com]Sent: Saturday, July 13, 2013 3:39 AMTo: cdicuser@developer.cisco.comSubject: New Message from Snehal_Vasant_Sakpal (simulated) in Unity Connection(CUC) - CUMI Questions: RE: How to access messages (.WAV file) from CUMISnehal_Vasant_Sakpal (simulated) has created a new message in the forum "CUMI Questions": -------------------------------------------------------------- Hi all,I am new to using this CUMI API as well as with GET requests and allI am trying to write a code via which i want each user to be able to see his voicemail messages and even play voicemailsi know nothing as to how to go for this. I have googled a lott and could just find the get request for e.g.1GET /vmrest/mailbox/folders/inbox/messages.But to write this from the code behind in csharp or .net i dont know I tried using the following code from one of the postsMemoryStream 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;But over here i just know my unity server name and porti dont know the REST URL [Image removed by sender. emoticon]I need to finish this module in a weekCan anyone please help me with the code. its reallly urgentThanks--To respond to this post, please click the following link: http://developer.cisco.com/web/cuc/forums/-/message_boards/view_message/17159705 or simply reply to this email.Subject: RE: How to access messages (.WAV file) from CUMI Replied by: Snehal_Vasant_Sakpal (simulated) on 16-07-2013 12:27:35 AMHi Loyd,Thanks for a quick replyI used the same query to get all inbox messagesGET /vmrest/mailbox/folders/inbox/messages?userobjectid=0d3fd550-6c76-4492-b0f4-aa835da300f7I tried putting this URL in browser(internet explorer) [url=http://<servername:8443/vmrest/mailbox/folders/inbox/messages?userobjectid=<object]http://<servername:8443/vmrest/mailbox/folders/inbox/messages?userobjectid=<object-id> but it gives me a 404 error saying the requested resource() is not available
where am I going wrong here? is there any changes in the setting on the server or the configurations that i need to do?Also the code that i had pasted above was used to get the response . But it didnt help
. Nothing is coming as an outputSo will it be possible for you to do some changes in the above code . Will really appreciate your help as my deadline is nearing byThanksSubject: RE: New Message from Snehal_Vasant_Sakpal (simulated) in Unity Connection(C Replied by: Loyd Vest on 16-07-2013 08:11:43 AMSnehal,You’re mis-understanding. You have to first get the object id of the User Mailbox as it exists on your system (i.e. the object id is unique to your system), and then use that object id to request the messages. You’re Object ID will look something like “0d3fd550-6c76-4492-b0f4-aa835da300f7”, which is the object id of a user mailbox on my lab system. If you don’t specify a valid User Object Id of a user on your system, of course that would return a 404 not found, since it doesn’t exist.So you first do a GET on the user’s:https://<servername>:8443/vmrest/usersThis will return you the list of all the users on the system. You then use the ObjectId returned in that list for the specific user for which you are wanting to retrieve the email in their inbox. You will then use that ObjectID in the query to get the inbox messages, as follows:https://<servername>:8443/vmrest/mailbox/folders/inbox/messages?userobjectid=<replace with objectid<https://%3cservername%3e:8443/vmrest/mailbox/folders/inbox/messages?userobjectid=%3creplace%20with%20objectid> of user from above query>[http://www.cisco.com/swa/i/logo.gif]Loyd D. VestSR. Custom Software EngineerAdvanced Services/Customer Collaboration Service Line/Custom Engineering Servicesloydv@cisco.com<mailto:loydv@cisco.com>Phone :412-237-6214Mobile :304-646-0563This e-mail may contain confidential and privileged material for the sole use of the intended recipient. Any review, use, distribution or disclosure by others is strictly prohibited. If you are not the intended recipient (or authorized to receive for the recipient), please contact the sender by reply e-mail and delete all copies of this message.From: Cisco Developer Community Forums [mailto:cdicuser@developer.cisco.com]Sent: Tuesday, July 16, 2013 1:28 AMTo: cdicuser@developer.cisco.comSubject: New Message from Snehal_Vasant_Sakpal (simulated) in Unity Connection(CUC) - CUMI Questions: RE: How to access messages (.WAV file) from CUMISnehal_Vasant_Sakpal (simulated) has created a new message in the forum "CUMI Questions": -------------------------------------------------------------- Hi Loyd,Thanks for a quick replyI used the same query to get all inbox messagesGET /vmrest/mailbox/folders/inbox/messages?userobjectid=0d3fd550-6c76-4492-b0f4-aa835da300f7I tried putting this URL in browser(internet explorer) [url=http://<servername:8443/vmrest/mailbox/folders/inbox/messages?userobjectid=<object]http://<servername:8443/vmrest/mailbox/folders/inbox/messages?userobjectid=<object-id> but it gives me a 404 error saying the requested resource() is not available [Image removed by sender. emoticon]where am I going wrong here? is there any changes in the setting on the server or the configurations that i need to do?Also the code that i had pasted above was used to get the response . But it didnt help [Image removed by sender. emoticon] . Nothing is coming as an outputSo will it be possible for you to do some changes in the above code . Will really appreciate your help as my deadline is nearing byThanks--To respond to this post, please click the following link: http://developer.cisco.com/web/cuc/forums/-/message_boards/view_message/17228566 or simply reply to this email.Subject: RE: How to access messages (.WAV file) from CUMI Replied by: Snehal_Vasant_Sakpal (simulated) on 18-07-2013 06:17:38 AMLoyd,I am trying to do the exact same thing that you suggessted.I did a GET https://<servername>:8443/vmrest/users, got the object id and then i did [url=https://%3cservername%3e:8443/vmrest/mailbox/folders/inbox/messages?userobjectid=<replace]https://<servername>:8443/vmrest/mailbox/folders/inbox/messages?userobjectid=<replace with objectid>I get an error -"The remote server returned a 404 error" 
1)My unity server version is 7.1.5.34900-7 . So is what I am trying to do possible with this version2)Is there anything with the account (username:password) role that i am using to access the inbox. Should it have any special rights or anything like that3)What are the settings on the server or in the code that you using because of which you are able to access and I am not?Thanks in advance for your helpSubject: RE: How to access messages (.WAV file) from CUMI Replied by: Snehal_Vasant_Sakpal (simulated) on 22-07-2013 02:05:26 AMHi Loyd,Recently while googling i found that in order to access the messages via CUMI API, you need to do the following- Navigate to System Settings > Advanced > API Settings in Cisco Unity Connection Administration.
- Check the Allow Access to Secure Message Recordings through CUMI check box, and click Save
However this option is available only from version 8 and I have unity version 7Now how do i get this done. Please reply as soon as you can as i need to get this in a very less timeThanks