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
Company Phone Number "Label"/"Name" Field
Tags: rest api, sdk
Feb 16, 2023 at 2:11pm   •   1 replies  •  0 likes
Nate Breeden

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!

1 Answer
answered on Feb 17, 2023 at 3:58am  

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


 1



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