Skip to main content

 

URI: "https://platform.ringcentral.com/restapi/v1.0/account/~/phone-number/{PhoneID}"
Json: “{"usageType":"DirectNumber","extension":{"id":"{EXTID"},"type":"VoiceOnly"}”
Method: PUT


Provides me with a 200 success.


uri         : https://platform.ringcentral.com/restapi/v1.0/account/{EXTID}/phone-number/{PhoneID}
id          : {PhoneID}
phoneNumber : {Phone Number}
paymentType : Local
location    : {Redacted}
type        : FaxOnly
usageType   : DirectNumber
extension   : @{uri=https://platform.ringcentral.com/restapi/v1.0/account/{EXTID}/extension/{ID}; id={ID}; extensionNumber={ext}}
status      : Normal
label       : {Redacted}
primary     : False


“type” is never actually updated to anything. This must be a bug right?

That is not supported. There is no PUT method for that endpoint and I am not sure about the fact that it returns 200 OK.

There is no public API for changing the phone number type.


Why isn’t there any public API for changing the phone number type? Is it something that can be added in the future?

When bulk provisioning numbers are being created as Voice Only when I need them VoiceFax. This means I have to manually change them in portal.


Why isn’t there any public API for changing the phone number type? Is it something that can be added in the future?

When bulk provisioning numbers are being created as Voice Only when I need them VoiceFax. This means I have to manually change them in portal.

Sorry, I notice now the API is public as Beta now.

To change the type of a number, you can only set the “type” body param (without the usageType or the extension params). This limitation will be fixed when the API goes GA.
 


Thanks Phong, I appreciate you looking into this!

      Yes, I did see the the API. Always very helpful! Following your directions, It demands the “UsageType”:


Json: '{"type":"VoiceOnly"}'
Method: Put
CMN-101
{
  "errorCode" : "InvalidParameter",
  "message" : "Parameter "usageType] value is invalid.",
  "errors" : {
    "errorCode" : "CMN-101",
    "message" : "Parameter eusageType] value is invalid.",
    "parameterName" : "usageType"
  } ],
  "parameterName" : "usageType"
}

 

Changing to Method Patch I get AGW-404 on every request

Trying from the built in knowledgebase under “Assign phone Number”(which the numbers in question are already assigned) I again "Parameter itype] value is invalid." on that patch request. I have no idea why the the Devsite patch is returning different that my internal patch, they appear to be identical.

 

Let me know if I just need to wait for RC to work the Beta kinks out. I am very happy that there is new features and don’t want to be a stick in the mud!


Thanks Phong, I appreciate you looking into this!

      Yes, I did see the the API. Always very helpful! Following your directions, It demands the “UsageType”:


Json: '{"type":"VoiceOnly"}'
Method: Put
CMN-101
{
  "errorCode" : "InvalidParameter",
  "message" : "Parameter "usageType] value is invalid.",
  "errors" : {
    "errorCode" : "CMN-101",
    "message" : "Parameter eusageType] value is invalid.",
    "parameterName" : "usageType"
  } ],
  "parameterName" : "usageType"
}

 

Changing to Method Patch I get AGW-404 on every request

Trying from the built in knowledgebase under “Assign phone Number”(which the numbers in question are already assigned) I again "Parameter itype] value is invalid." on that patch request. I have no idea why the the Devsite patch is returning different that my internal patch, they appear to be identical.

 

Let me know if I just need to wait for RC to work the Beta kinks out. I am very happy that there is new features and don’t want to be a stick in the mud!

 

No, the method must be PATCH. If you can run Node JS, can you run this code

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

RINGCENTRAL_CLIENTID = "YourAppClientId";
RINGCENTRAL_CLIENTSECRET = "YourAppClientSecret";
RINGCENTRAL_SERVER = 'https://platform.ringcentral.com'

RC_USER_JWT = "User JWT Token"

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

var platform = rcsdk.platform();

platform.login({ jwt : RC_USER_JWT })

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

async function read_user_phone_numbers(){
var endpoint = '/restapi/v1.0/account/~/extension/~/phone-number'
try{
var params = {
usageType: m "DirectNumber"]
}
const resp = await platform.get(endpoint, params)
var jsonObj = await resp.json()
for (var record of jsonObj.records){
if (record.phoneNumber == "+phone number to be changed the type"){
await change_phone_number_type(record.id)
break
}
}
}catch (e){
console.log(e.message)
}
}

async function change_phone_number_type(phoneNumberId){
var endpoint = `/restapi/v2/accounts/~/phone-numbers/${phoneNumberId}`
try{
var params = {
type: "VoiceFax", // OR Other type
}
const resp = await platform.patch(endpoint, params)
var jsonObj = await resp.json()
console.log(jsonObj)
}catch (e){
console.log(e.response.headers)
console.log(e.message)
}
}

If this fails, can you share the rcrequestid from the header?


Reply