question

Mike Robinson avatar image
Mike Robinson asked ·

Unassigned Extensions

Hello - is there a method to assign an unassigned extension to a user via the API? I tried 2 methods and neither worked so I am curious if I am doing something wrong or if there just isn't a way to do this yet.

I first tried using 'Update Device': https://platform.devtest.ringcentral.com/restapi/v1.0/account/accountId/device/deviceId
I used a deviceId of an unassigned extension and passed in the extension id of an existing user. This method resulted in the following error: "Unknown device update use case".

I then tried using 'Update Extension': https://platform.devtest.ringcentral.com/restapi/v1.0/account/accountId/extension/extensionId
I used the extensionId of an unassigned extension, and passed in the user contact information (the user did not exist in RC). The API request went through, but when I went to look in RC, the extension was still in the 'Unassigned Extensions' section and when I clicked on the link, it brought up a read-only page showing the contact info I added to the extension but nothing could be updated. I had to assign the extension to someone else manually to get the extension out of the 'Unassigned' list.

Any help/thoughts would be appreciated - thank you!


apiextension api
1 |1000 characters needed characters left characters exceeded

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

Phong Vu avatar image
Phong Vu answered ·

Here is how you can assign an unassigned extension. I assumed that you can read and use Node JS and RingCentral JS SDK. But if not, let me know.

function find_unassigned_extensions(){
    platform.get('/account/~/extension')
        .then(function (resp) {
          var jsonObj = resp.json()
          for (var record of jsonObj.records){
            if (record.type == "User" && record.status == "Unassigned"){
              //console.log(JSON.stringify(record))
              //console.log("======")
              if (record.id == "260981XXX"){ // The extension you want to assi
                assign_this_extension_to_a_new_user(record.id)
              }
            }
          }
        })
        .catch(function(e){
          console.log(e.message)
        });
}

function assign_this_extension_to_a_new_user(extId){
  var params = {
    status: "Enabled",
    extensionNumber: 202, // leave this or make sure the number are not being used
    contact: {
      firstName: "Demo",
      lastName: "Automated",
      company: "Test",
      jobTitle: "consultant",
      email: "valid.email@address.com",
      emailAsLoginName: true
    },
    password: "some-password"
  }
  platform.put('/account/~/extension/' + extId, params)
      .then(function (resp) {
        var jsonObj = resp.json()
        console.log(jsonObj)
      })
      .catch(function(e){
        console.log(e.message)
      });
}


1 comment Share
1 |1000 characters needed characters left characters exceeded

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

Thanks Phong!

I was missing the 'status: Enabled' in my function call which is what caused mine to not work. After adding that param, all was good.

1 Like 1 · ·
Mike Robinson avatar image
Mike Robinson answered ·

Appreciate the response Phong! Node is just fine - that is the same function call I used but our params don't quite match up, so I will try it again and report back.

Share
1 |1000 characters needed characters left characters exceeded

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

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

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