question

grant-botma avatar image
grant-botma asked benjamin-dean commented

Send SMS via curl request

I'm trying to test out different API functionality before beginning to build an application to link a client's CRM to the Ring Central API.


I've gone through the "Getting Started" tutorial, and have successfully retrieved an access token and logged in.


I'm going through the "Message" tutorial, and I'm trying to send a POST request to send a test message. I couldn't figure out how to format the JSON correctly in the Rest Client chrome extension, so I'm replicating the POST message in the "Message" tutorial in a curl request. Here's the request I'm running from the command line (the fields in all caps are filled in with the correct values):


curl -X POST -H "Content-Type: application/json" -H "Authorization: Bearer  MY-ACCESS-TOKEN" -H "Accept: application/json"  -d '{"to": [{"phoneNumber": "PERSONAL-PHONE-NUMBER"}], "from": {"phoneNumber": "SANDBOX-ACCOUNT-NUMBER"}, "text": "this is the message"}' https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/sms

And here's the response I'm getting:


{
                 
  "errorCode" : "FeatureNotAvailable",
  "message" : "The requested feature is not available",
  "errors" : [ {
                 
    "errorCode" : "MSG-242",
    "message" : "The requested feature is not available"
  } ]

}



Any Idea what might be going wrong?


               
rest api
1 |3000

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

benjamin-dean avatar image
benjamin-dean answered
Has the User / Extension in the Sandbox account been enabled? (do you see a green marker next to their name while viewing in service.devtest.ringcentral.com ?)

If you are sure that User/Extension has been enabled, is the account authorized to send SMS? A good test for this is to try sending an SMS from the Desktop soft phone in Sandbox mode.
1 |3000

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

grant-botma avatar image
grant-botma answered
Yes, the user extension has been enabled.  If I'm logged into my actual account, I'm able to send external text messages from the soft phone, however when I'm logged into my sandbox account and I try to send an external text, I get this error message:

"Alert: Your extension does not support external text messaging. Please contact your account administrator."

Is there any way to enable some sort of stubbed external texting in Sandbox? If not, how should I go about testing my application's texting feature?
1 |3000

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

benjamin-dean avatar image
benjamin-dean answered
In the OAuth Settings panel of the Settings for your application (where you obtained the API Keys), have you enabled the SMS permission for this app?

Here is a screenshot of what you would want to see...


1 |3000

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

grant-botma avatar image
grant-botma answered
Yes, that's how I set it up.
1 |3000

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

benjamin-dean avatar image
benjamin-dean answered
Alright, so that's one question down...

I just tried this from my console successfully, using this cURL request (after obtaining a valid access_token):
curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" --header "Authorization: Bearer REPLACE_WITH_ACCESS_TOKEN" -d "{\"from\":{\"extensionNumber\":\"\",\"location\":\"\",\"name\":\"\",\"phoneNumber\":\"16506429233\"},\"to\":[{\"extensionNumber\":\"\",\"location\":\"\",\"name\":\"\",\"phoneNumber\":\"14158905908\"}],\"text\":\"This is my API Explorer SMS message.\"}" "https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/sms";
I'm using: 
curl 7.37.1 (x86_64-apple-darwin14.0) libcurl/7.37.1 SecureTransport zlib/1.2.5

I kept receiving Unsupported Media Type errors when I was using the -H flag for headers instead of --headers.

You can use our API Explorer for sending test SMS messages via the API as well. Could you try it in the API Explorer and share the response please sir.

https://developers.ringcentral.com/api-explorer/latest/index.html#/!/Messages/sendSMS
1 |3000

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

grant-botma avatar image
grant-botma answered
I'm getting various versions of the same error in different environments:

via curl-

My API call:

curl -X POST --header "Content-Type: application/json" --header "Accept: application/json" --header "Authorization: Bearer VALID_AUTH_TOKEN" -d "{\"from\":{\"extensionNumber\":\"\",\"location\":\"\",\"name\":\"\",\"phoneNumber\":\"SANDBOX_PHONE_NUMBER\"},\"to\":[{\"extensionNumber\":\"\",\"location\":\"\",\"name\":\"\",\"phoneNumber\":\"EXTERNAL_PHONE_NUMBER\"}],\"text\":\"This is my API Explorer SMS message.\"}" "https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/sms";

And here's the response I'm getting:

{
                 
  "errorCode" : "FeatureNotAvailable",
  "message" : "The requested feature is not available",
  "errors" : [ {
    "errorCode" : "MSG-242",
    "message" : "The requested feature is not available"

  }

I get the same response whether I'm using -H or --header for my header flag.

via API explorer-


and here's the response:


soft phone's response-



Here's the permissions page



Note- If I'm logged into soft phone with the non-sandbox account, I can send external text messages without any issue. Do I need to toggle anything from within my https://service.devtest.ringcentral.com account or the https://service.ringcentral.com account?

My apologies if this is overkill, I just figure that more info might be helpful!


1 |3000

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

benjamin-dean avatar image
benjamin-dean answered benjamin-dean commented
OK, I think I got it all figured out for you...

You are trying to use the main company number for the Sandbox account (you cannot send SMS from that number). What you want to do is create a new user on https://service.devtest.ringcentral.com and then...

Go to the Phones & Numbers section (URI below), add a direct number and add a phone for the user from the previous step. Also, please make sure that you have activated the user account, you can see this in the user so you can see they are enabled on the list of users.

Here is a screenshot of an account that I am able to use while sending SMS.


Please complete these steps and try again and you should be able to send the SMS from the soft phone (when you're logged in as that user in the soft phone or via the API as the newly created user and using their number as the "from" number in your API request).

Let me know.
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.

grant-botma avatar image grant-botma commented ·
Fixed. Thank you so much!
1 Like 1 ·
benjamin-dean avatar image benjamin-dean commented ·
Glad to hear you're back in action.
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