News & Announcements User Community Developer Community

Welcome to the RingCentral Community

Please note the community is currently under maintenance and is read-only.

Search
Make sure to review our Terms of Use and Community Guidelines.
  Please note the community is currently under maintenance and is read-only.
Home » Developers
Send SMS via curl request
Tags: rest api
Mar 15, 2016 at 1:54pm   •   7 replies  •  0 likes
grant-botma

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?

7 Answers
answered on Mar 18, 2016 at 3:55pm  
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.

 0
answered on Mar 17, 2016 at 10:31pm  
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
answered on Mar 17, 2016 at 4:19pm  
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

 0
answered on Mar 17, 2016 at 3:28pm  
Yes, that's how I set it up.

 0
answered on Mar 17, 2016 at 2:53pm  
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...



 0
answered on Mar 16, 2016 at 1:02pm  
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?

 0
answered on Mar 15, 2016 at 4:53pm  
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.

 0



A new Community is coming to RingCentral!

Posts are currently read-only as we transition into our new platform.

We thank you for your patience
during this downtime.

Try Workflow Builder

Did you know you can easily automate tasks like responding to SMS, team messages, and more? Plus it's included with RingCentral Video and RingEX plans!

Try RingCentral Workflow Builder

PRODUCTS
RingEX
Message
Video
Phone
OPEN ECOSYSTEM
Developer Platform
APIs
Integrated Apps
App Gallery
Developer support
Games and rewards

RESOURCES
Resource center
Blog
Product Releases
Accessibility
QUICK LINKS
App Download
RingCentral App login
Admin Portal Login
Contact Sales
© 1999-2024 RingCentral, Inc. All rights reserved. Legal Privacy Notice Site Map Contact Us