question

Nate Breeden avatar image
Nate Breeden asked Phong Vu commented

Company Phone Number "Label"/"Name" Field

We have 1500 phone numbers and need to label a good amount of them for tracking purposes, which I've started working on a Python script to accomplish.


_req = platform.get(f'/restapi/v1.0/account/{accountId}/phone-number/') #this will be called once to get numbers
_tt = json.loads(_req.text())
_extId = _tt['records'][0]['id']
_pp = platform.get(f'/restapi/v1.0/account/{accountId}/phone-number/{_extId}')
_jr = json.loads(_pp.text())
_jr['label'] = "test"
_put = platform.put(f'/restapi/v1.0/account/{accountId}/phone-number/{_extId}',_jr)

Which returns

ringcentral.http.api_exception.ApiException: Parameter [phoneNumber] value is invalid.

even though I'm passing the same data and "phoneNumber" just changing the label? Trying "post" instead of "put" returns invalid resource so I know that's not the issue


This is the field we are trying to change via the API

1676584151454.png


Thanks as always!

rest apisdk
1676584151454.png (20.3 KiB)
1 |3000

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

1 Answer

Nate Breeden avatar image
Nate Breeden answered Phong Vu commented

Feeling a bit silly not thinking of this last night, but I figured out how to do this.

This is what works for my testing of the calls in case anyone else is trying to do this:


_req = platform.get(f'/restapi/v1.0/account/{accountId}/phone-number/') #this will be called once to get numbers
_tt = json.loads(_req.text())
_extId = _tt['records'][0]['id']
_setParams = { 
    'label': 'test'
}
_put = platform.post(f'/restapi/v1.0/account/{accountId}/phone-number/{_extId}',setParams)


So instead of sending all of the "Get" as params, just sending the label specifically as a param fixes things. Thinking sending the phoneNumber as a parameter is kicking back with that error since you shouldn't be able to change the phone number, so it's not an option as a parameter to send through that call, and most likely same for other fields returned in the "Get".

2 comments
1 |3000

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

KHANH TRUONG avatar image KHANH TRUONG commented ·

@Phong Vu @Nate Breeden

Is this edit phone number's label method still working?

I can't find this endpoint on official api reference.


the closest I got is


platform . put ( f '/restapi/v1.0/account/~/phone-number/ { phoneId } ' , _setParams )


But it required [EditAccounts] permissions, this permission is not available in my console neither


Please advise

0 Likes 0 ·
Phong Vu avatar image Phong Vu ♦♦ KHANH TRUONG commented ·

That is the correct method and API. To add the EditAccounts permission to your app, submit a support request with the app client id to the dev support channel.

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