question

Daniel Lopez avatar image
Daniel Lopez asked ·

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'

})

errorapi smssending sms
1 |1000 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.

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()
Share
1 |1000 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 ·

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 Share
1 |1000 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 ·

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 Share
1 |1000 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 ·


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 Share
1 |1000 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 · ·
Daniel Lopez avatar image Daniel Lopez Phong Vu ♦♦ ·

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

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

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"

}

Share
1 |1000 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.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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