Skip to main content

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!

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


Reply