question

Daniel Lopez avatar image
Daniel Lopez asked Daniel Lopez commented

SMS IN SANDBOX NOT WORKING PYTHON

Good day, im starting to test a really simple SMS app, i tried to test the default python sms code, but no SMS gets sent neither internal o real numbres, i dont get any errors, simply nothing gets sent. heres the code im using


from ringcentral import SDK

RECIPIENT = '+15622916474'

RINGCENTRAL_CLIENTID = 'XXXXXXXXX'

RINGCENTRAL_CLIENTSECRET = 'XXXXXXXXXXX'

RINGCENTRAL_SERVER = 'https://platform.devtest.ringcentral.com'

RINGCENTRAL_USERNAME = '+12107291286'

RINGCENTRAL_PASSWORD = 'XXXXXX'

RINGCENTRAL_EXTENSION = '101'

rcsdk = SDK( RINGCENTRAL_CLIENTID, RINGCENTRAL_CLIENTSECRET, RINGCENTRAL_SERVER)

platform = rcsdk.platform()

platform.login(RINGCENTRAL_USERNAME, RINGCENTRAL_EXTENSION, RINGCENTRAL_PASSWORD)

platform.post('/restapi/v1.0/account/~/extension/~/sms',

{

'from' : { 'phoneNumber': RINGCENTRAL_USERNAME },

'to' : [ {'phoneNumber': RECIPIENT} ],

'text' : 'Hello World from Python'

})

getting started
1 |1500 characters needed characters left characters exceeded

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

Daniel Lopez avatar image
Daniel Lopez answered Daniel Lopez commented

the '+12107291286' , is the number they assigned us in the sandbox account, the other one is one of our regular RC numbers


tried using my mobile number and got the same.


{

"uri" : "https://platform.devtest.ringcentral.com/restapi/v1.0/account/280008004/extension/280008004/message-store/8373371004",

"id" : 8373371004,

"to" : [ {

"phoneNumber" : "+1562572XXXX"

} ],

"from" : {

"phoneNumber" : "+12107291286",

"name" : "Telemarketing ."

},

"type" : "SMS",

"creationTime" : "2020-06-30T21:14:08.000Z",

"readStatus" : "Read",

"priority" : "Normal",

"attachments" : [ {

"id" : 8373371004,

"uri" : "https://platform.devtest.ringcentral.com/restapi/v1.0/account/280008004/extension/280008004/message-store/8373371004/content/8373371004",

"type" : "Text",

"contentType" : "text/plain"

} ],

"direction" : "Outbound",

"availability" : "Alive",

"subject" : "Test SMS using a RingCentral Developer account - tester",

"messageStatus" : "SendingFailed",

"smsSendingAttemptsCount" : 1,

"conversationId" : 4763525412780169249,

"conversation" : {

"id" : "4763525412780169249",

"uri" : "https://platform.devtest.ringcentral.com/restapi/v1.0/conversation/4763525412780169249"

},

"lastModifiedTime" : "2020-06-30T21:14:08.872Z"

}

2 comments
1 |1500 characters needed characters left characters exceeded

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

I added a direct number to the extension 101. Can you try again with the main company number and also with the direct number (xxx) xxx-2635.

0 Likes 0 ·

its working now! and we already graduated to production, thanks a lot!

1 Like 1 ·
Phong Vu avatar image
Phong Vu answered

Can you print the response as shown below

resp = platform.post('/restapi/v1.0/account/~/extension/~/sms',
              {
                  'from' : { 'phoneNumber': RINGCENTRAL_USERNAME },
                  'to'   : [ {'phoneNumber': RECIPIENT} ],
                  'text' : 'Hello World from Python'
              })

print resp.text()
1 |1500 characters needed characters left characters exceeded

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

Daniel Lopez avatar image
Daniel Lopez answered Phong Vu edited

Thanks heres the response

{
"uri" : "https://platform.devtest.ringcentral.com/restapi/v1.0/account/280008004/extension/280008004/message-store/8373199004",
"id" : 8373199004,
"to" : [ {
"phoneNumber" : "+15622916474",
"location" : "Downey, CA"
} ],
"from" : {
"phoneNumber" : "+12107291286",
"name" : "Telemarketing ."
},
"type" : "SMS",
"creationTime" : "2020-06-30T19:59:09.000Z",
"readStatus" : "Read",
"priority" : "Normal",
"attachments" : [ {
"id" : 8373199004,
"uri" : "https://platform.devtest.ringcentral.com/restapi/v1.0/account/280008004/extension/280008004/message-store/8373199004/content/8373199004",
"type" : "Text",
"contentType" : "text/plain"
} ],
"direction" : "Outbound",
"availability" : "Alive",
"subject" : "Test SMS using a RingCentral Developer account - Hello World from Python",
"messageStatus" : "Queued",
"smsSendingAttemptsCount" : 1,
"conversationId" : 4763525408982918811,
"conversation" : {
"id" : "4763525408982918811",
"uri" : "https://platform.devtest.ringcentral.com/restapi/v1.0/conversation/4763525408982918811"
},
"lastModifiedTime" : "2020-06-30T19:59:09.628Z"
}


1 comment
1 |1500 characters needed characters left characters exceeded

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

Your message is on queued ("messageStatus" : "Queued"). You should use the message id ("id" : 8373199004) to query the message status to see if it finally sent or failed.

resp = platform.get('/account/~/extension/~/message-store/8373199004')
print (resp.text())
0 Likes 0 ·
Daniel Lopez avatar image
Daniel Lopez answered Phong Vu edited

it says failed, what can be causing that, tried doing it from the console and they don't get sent, but the callout feature works.

{
"uri" : "https://platform.devtest.ringcentral.com/restapi/v1.0/account/280008004/extension/280008004/message-store/8373199004",
"id" : 8373199004,
"to" : [ {
"phoneNumber" : "+15622916474",
"location" : "Downey, CA"
} ],
"from" : {
"phoneNumber" : "+12107291286",
"name" : "Telemarketing ."
},
"type" : "SMS",
"creationTime" : "2020-06-30T19:59:09.000Z",
"readStatus" : "Read",
"priority" : "Normal",
"attachments" : [ {
"id" : 8373199004,
"uri" : "https://platform.devtest.ringcentral.com/restapi/v1.0/account/280008004/extension/280008004/message-store/8373199004/content/8373199004",
"type" : "Text",
"contentType" : "text/plain"
} ],
"direction" : "Outbound",
"availability" : "Alive",
"subject" : "Test SMS using a RingCentral Developer account - Hello World from Python",
"messageStatus" : "SendingFailed",
"smsSendingAttemptsCount" : 1,
"conversationId" : 4763525408982918811,
"conversation" : {
"id" : "4763525408982918811",
"uri" : "https://platform.devtest.ringcentral.com/restapi/v1.0/conversation/4763525408982918811"
},
"lastModifiedTime" : "2020-06-30T19:59:10.355Z"
}


2 comments
1 |1500 characters needed characters left characters exceeded

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

both numbers in this example are from RC

0 Likes 0 ·

The number is your main company number. Can you call this endpoint and read the record['feature'] to see if the number has the SMS feature enabled.

platform.get('/account/~/extension/~/phone-number')


0 Likes 0 ·
Daniel Lopez avatar image
Daniel Lopez answered Daniel Lopez commented


This is what i got

{
"uri" : "https://platform.devtest.ringcentral.com/restapi/v1.0/account/280008004/extension/280008004/phone-number?page=1&perPage=100",
"records" : [ {
"features" : [ "CallerId", "SmsSender", "MmsSender" ],
"uri" : "https://platform.devtest.ringcentral.com/restapi/v1.0/account/280008004/phone-number/343601004",
"id" : 343601004,
"phoneNumber" : "+12107291286",
"paymentType" : "Local",
"type" : "VoiceFax",
"usageType" : "MainCompanyNumber",
"status" : "Normal",
"country" : {
"uri" : "https://platform.devtest.ringcentral.com/restapi/v1.0/dictionary/country/1",
"id" : "1",
"name" : "United States"
}
} ],
"paging" : {
"page" : 1,
"totalPages" : 1,
"perPage" : 100,
"totalElements" : 1,
"pageStart" : 0,
"pageEnd" : 0
},
"navigation" : {
"firstPage" : {
"uri" : "https://platform.devtest.ringcentral.com/restapi/v1.0/account/280008004/extension/280008004/phone-number?page=1&perPage=100"
},
"lastPage" : {
"uri" : "https://platform.devtest.ringcentral.com/restapi/v1.0/account/280008004/extension/280008004/phone-number?page=1&perPage=100"
}
}
}


2 comments
1 |1500 characters needed characters left characters exceeded

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

So the problem must be from the recipient number. You said both are RC numbers. what account does the other number belong to? Can you send to your mobile number?

0 Likes 0 ·

already tried it and i still get the same, call out feature does work

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