Solved

SMS IN SANDBOX NOT WORKING PYTHON

  • 30 June 2020
  • 5 replies
  • 1311 views

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'

})

icon

Best answer by Daniel604565018 30 June 2020, 23:18

View original

5 replies

Userlevel 1

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()

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"
}


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"
}



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"
}
}
}


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"

}

Reply