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
Trying to test CallOut in the Sandbox
Tags: rest api
Nov 24, 2020 at 8:14am   •   4 replies  •  0 likes
Trent Grandey

I am trying to test the CallOut API in a new app I'm developing. I've gotten pretty far. I have installed the RC Phone and can call into that phone with the sandbox account phone number.


So back to my app, I need to get the deviceId of that RC Phone. To get the deviceId, I need the extensionId. So I've called the GetExtensionList and I do get the info on my one sandbox extension. I don't see an extensionId. Given some of the other posts I've read and the urls that are shown on the api calls, I see them using the accountId as the extensionId.

So, I've called GetDevice with https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/device and I've also tried with accountId in both places instead of the tilde. No matter what I try, the records value in the response is empty.

What am I doing wrong it trying to get the device to target? Any help would be greatly appreciated!

4 Answers
answered on Nov 24, 2020 at 2:09pm  

Here is the problem. You don't have a phone for your 101 user extension. Login your sandbox account, select the user -> numbers & phones and add a phone (select the RingCentral softphone) for your extension.

screen-shot-2020-11-24-at-20624-pm.png


 0
answered on Nov 24, 2020 at 8:34am  

@Phong Vu Just curious to know if RC phone support any device id? As per the question, it seems device response is empty because of using RC phone.

If I check following ref:

https://community.ringcentral.com/questions/10052/callout-using-mobiledesktop-app.html

you clearly mentioned:

"The RC mobile apps and the RC Desktop app do not register a device id so that you cannot find it from the extension device list. "

Correct me if I am missing anything


 0
answered on Nov 24, 2020 at 9:51am  

If there is no way to get a deviceId for any device in the sandbox, is there ANY way to test a CallOut from the sandbox? I have a Ring Central Poly phone. Is there a way to log that into the sandbox?

Any other ideas???


 0
on Nov 24, 2020 at 10:03am   •  0 likes

Unfortunately, that RingCentral Phone app does not register its device Id to the system. I wonder how you could login that RC Phone app with your sandbox account user's credentials. Or did I misunderstand that you logged in with your production account and receive incoming call from your sandbox number? Please clarify.

This is the only phone app (scroll to the RC Phone Desktop) that can be used with the sandbox account, provided you switch the app to "sandbox" mode (e.g. fn-command-f2 on Mac).

We are working on the possibility to have other RC app to register its device Id but it is not possible right now.

on Nov 24, 2020 at 10:10am   •  0 likes

This is the app I'm using. I switched it to Sandbox and logged in with my sandbox credentials. I can call from my mobile phone to this sandbox number and that works fine.

So if this doesn't give a deviceId, then there is nothing else that works in the Sandbox that does give a deviceId?

If I want to test, do I create an app with CallControl and then test some other call control enough to get it promoted to production and THEN I can test CallOut?
1606241277488.png

on Nov 24, 2020 at 10:17am   •  0 likes

Yes, this is the RingCentral softphone app (RC Phone Desktop).

Yes, you need an app with the CallControl permission to call the call-out API. My code shared above should work. If you still don't see the device Id, let me know your app client id.

on Nov 24, 2020 at 10:23am   •  0 likes

I tested the API.. This app actually give device id in response

the API url is: https://platform.devtest.ringcentral.com/restapi/v1.0/account/~/extension/~/device method GET

on Nov 24, 2020 at 10:29am   •  0 likes

Here is my API call from Postman. Can you see anything wrong? I'm logged in with username "+14243520781" and extension "101" (and password) from my app details in the sandbox. That gives me the bearer token I'm using.

1606242438758.png

on Nov 24, 2020 at 10:34am   •  0 likes

You logged into the app with same extension right? The access_token generated from token api should be from using same ext

on Nov 24, 2020 at 10:48am   •  0 likes

Yes. Using 101 for all logins.

on Nov 24, 2020 at 10:21am   •  0 likes

The app client id is -QWCx-B0RO-4UJZVS5B9Hw

It has the CallControl and ReadAccounts permissions needed to run the code above, but I just have nothing with a deviceId.

Are you saying the RC Phone Desktop does or does not register a deviceId?

answered on Nov 24, 2020 at 8:22am  

Her is all what you need to implement in Node JS. Let me know if you have problem or you want in other programming language.

const RingCentral = require('@ringcentral/sdk').SDK

RINGCENTRAL_CLIENTID = 'your-app-client-id'
RINGCENTRAL_CLIENTSECRET = 'your-app-client-secret'
RINGCENTRAL_SERVER = 'https://platform.devtest.ringcentral.com'

RINGCENTRAL_USERNAME = 'username'
RINGCENTRAL_PASSWORD = 'password'
RINGCENTRAL_EXTENSION = 'ext-number'

const rcsdk = new RingCentral({
  server: RINGCENTRAL_SERVER,
  clientId: RINGCENTRAL_CLIENTID,
  clientSecret: RINGCENTRAL_CLIENTSECRET
})

var platform = rcsdk.platform();

rcsdk.login({
        username: RINGCENTRAL_USERNAME,
        extension: RINGCENTRAL_EXTENSION,
        password: RINGCENTRAL_PASSWORD
      })

platform.on(platform.events.loginSuccess, async function(e){
    console.log("Login success")
    get_extension_devices()
});

async function get_extension_devices() {
  console.log("get_extension_devices")
  try{
    var resp = await platform.get('/restapi/v1.0/account/~/extension/~/device')
    var jsonObj = await resp.json()
    for (var record of jsonObj.records){
      if (record.status == "Online"){
        console.log(record.status)
        console.log(record.id)
        call_out(record.id)
        break
      }
    }
  }catch(e){
    console.log(e.message)
  }
}

async function call_out(deviceId) {
  var params = {
    from: {
      deviceId: deviceId
    },
    to: {
      phoneNumber: "phone number to call"
    }
  }
  try{
    var resp = await platform.post('/restapi/v1.0/account/~/telephony/call-out', params)
    var jsonObj = await resp.json()
    console.log(JSON.stringify(jsonObj))
  }catch(e){
    console.log(e.message)
  }
}



 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