question

jason4335 avatar image
jason4335 asked Tyler Liu commented

Voicemail Message Retrieval

I have a Production API successfully retrieving message (sms, voicemails, faxes) data and we are storing that information in our database.


Now, we attempting to take the message id and attachment id and using it to retrieve the voicemail and we are getting this error.


{ "errorCode" : "CMN-102", "message" : "Resource for parameter [messageId] is not found", "errors" : [ { "errorCode" : "CMN-102", "message" : "Resource for parameter [messageId] is not found", "parameterName" : "messageId" } ], "parameterName" : "messageId" }



I am wondering if since the voicemail is coming in on our production phone number if attempting to access it with our sandbox phone number (and credentials) while testing is causing the "resource not found." I doubt it, but I need to ask.


Any other insight into what is causing this error would be helpful.


Our API endpoint is (pound symbols will replace actual variables in Coldfusion:


https://platform.devtest.ringcentral.com/restapi/v1.0/account/#setOwnerId#/extension/#setOwnerId#/message-store/#messageId#/content/#attachment_Id#


Thanks,


Jason


errors
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Tyler Liu avatar image
Tyler Liu answered
You cannot access production resource with sandbox credentials.
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

jason4335 avatar image
jason4335 answered jason4335 commented
So, you are telling me I cannot test my code in retrieving a voicemail attachment in SandBox?  I have to do it in Production?

I just want to confirm, because it may create unnecessary errors on the production side.


4 comments
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Tyler Liu avatar image Tyler Liu ♦ commented ·
You said "I am wondering if since the voicemail is coming in on our production phone number if attempting to access it with our sandbox phone number (and credentials)"

You can generate the voicemail in sandbox and access it in sandbox..  Sandbox env and production env are separated.
0 Likes 0 ·
jason4335 avatar image jason4335 commented ·
Ok, what is causing this error:

{ "errorCode" : "CMN-102", "message" : "Resource for parameter [messageId] is not found", "errors" : [ { "errorCode" : "CMN-102", "message" : "Resource for parameter [messageId] is not found", "parameterName" : "messageId" } ], "parameterName" : "messageId" } 
0 Likes 0 ·
Tyler Liu avatar image Tyler Liu ♦ commented ·
It simply means that messageId is not found on RingCentral server. Where did you get the messageId?
0 Likes 0 ·
jason4335 avatar image jason4335 commented ·
Message Id was parsed from a JSON string by a Reading Messages method created from your API.

Now, since you cannot leave a voicemail on Sandbox number for testing (I tried), I called our Production line and left a test message.

Then, I downloaded the message data through JSON and stored it on my server.  From what I can tell, it does not matter how you download the information (Sandbox or Production) because that information is unchanged.  

However, my concern is that if I left the voicemail on the Production phone number and trying to access the voicemail with Sandbox, then it may not work.  Maybe that is why I am getting the Message Id is not found.

If I can't retrieve a Production number voicemail with Sandbox, then how would I test my voicemail retrieval code in Sandbox...it seems to me I would have to test it on Production which would create errors on the Production side.

Please confirm that.

0 Likes 0 ·
jason4335 avatar image
jason4335 answered jason4335 commented
Also, I can still access my Sandbox credentials when making changes to my Application with SMS Sending and Getting Messages.  Those two methods still work on SandBox.
2 comments
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Tyler Liu avatar image Tyler Liu ♦ commented ·
Then how to reproduce the issue you reported? Do you mean you get messageId from sandbox and try to download it with production credentials?
0 Likes 0 ·
jason4335 avatar image jason4335 commented ·
Ok..let's forget about Production versus Sandbox.


0 Likes 0 ·
jason4335 avatar image
jason4335 answered Tyler Liu commented
I didn't get a response from my request above, so I went ahead and tested my code on production and it appears to retrieve the voicemail.

The problem is the documentation says that the file is audio/x-wav.

https://developer.ringcentral.com/api-docs/latest/index.html?section=RefMessages.html#!#MessageAttac...

However, the JSON get messages method returns audio/mpeg and my code checks the mime-type and it also says audio-mpeg.

However, when I write the file as an .mp3, the file is invalid.  

Suggestions please since the documentation is wrong.

Jason

5 comments
1 |3000

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Tyler Liu avatar image Tyler Liu ♦ commented ·
Some are wav files while some are mp3 files.

You can configure it in service web so that all future files will be in a single format.

However, when I write the file as an .mp3, the file is invalid.  

How do you know that file is invalid and how do you download the binary and save it as a file?  Could you please post sample code?
0 Likes 0 ·
jason4335 avatar image jason4335 commented ·
I use Coldfusion, but if you read what is going on, it's pretty easily to understand:

<cfif sandBoxStatus> <!--- SandBox--->
SANDBOX MODE<BR>
<cfset base_url = " https://platform.devtest.ringcentral.com"; />
<cfelse>
<!--- Production--->
<cfset base_url = " https://platform.ringcentral.com"; />
</cfif>

<cfset authorization = setTokenType & " " & setAccessToken />

<cfset voicemail_url = "/restapi/v1.0/account/#setOwnerId#/extension/#setOwnerId#/message-store/#messageId#/content/#attachment_Id#" />

<cfset final_url = base_url & voicemail_url />

<cfhttp
    method="get"
    url="#final_url#"
    resolveurl="no"
    getasbinary="yes"
    path="#getDirectory#\temp\" 
    file="#attachment_Id#.mp3"
>

<cfhttpparam type="header" name="authorization" value="#authorization#">

</cfhttp>

When the file is stored on the directly and path specific in the CFHTTP tag and I attempt to access it, it says it is an invalid file.


You can configure it in service web so that all future files will be in a single format.

How do you do this?

0 Likes 0 ·
Tyler Liu avatar image Tyler Liu ♦ commented ·
Try to save it as wav and see if it's still invalid. Just want to narrow down the problem: it could be an extension(mp3 vs wav) issue or it could be some coding issue (wrong way to read and save binary.)
0 Likes 0 ·
Tyler Liu avatar image Tyler Liu ♦ commented ·
> How do you do this?

Forgot the details. I will get back to you later.
0 Likes 0 ·
Tyler Liu avatar image Tyler Liu ♦ commented ·
In order to change default voicemail format, you can contact RC support. There seems no way for you to change it yourself.

By default it is mp3. But some accounts with long history might have different settings.
0 Likes 0 ·

Developer sandbox tools

Using the RingCentral Phone for Desktop, you can dial or receive test calls, send and receive test SMS or Fax messages in your sandbox environment.

Download RingCentral Phone for Desktop:

Tip: switch to the "sandbox mode" before logging in the app:

  • On MacOS: press "fn + command + f2" keys
  • On Windows: press "Ctrl + F2" keys