question

Chris Moreno avatar image
Chris Moreno asked Phong Vu commented

Read Message scope

I am trying to create an internal app for our company where we can retrived all faxes received and then archived them or search for them. I am however, running into problems with the permissions. When calling "GetMessageList" from the Message Store, I get this error.


In order to call this API endpoint for another extension, one of the following permissions [ReadMessages] have to be granted with extended scope to the authorized user.


i dont see a way to add this scope, what do I need to do?

rest apifaxpermissions
1 |1500 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.

1 Answer

Phong Vu avatar image
Phong Vu answered Phong Vu commented

The error message is misleading.

Unfortunately, there is no API to read the message store at the company level. You have to login your app with an admin user, read all extensions to get the extensions' id, then ready the user message store one by one using the extension id. Here is some sample code in Node JS. Hope this helps

var extensionList = []
async function get_extensions() {
  try {
    var resp = await platform.get('/restapi/v1.0/account/~/extension')
    var jsonObj = await resp.json
    for (var record of jsonObj.records){
        extensionList.push(record.id)
    }
    readExtensionMessageStore()
  }catch(e){
      console.log(e.message)
  }
}

async function readExtensionMessageStore(){
  async.each(extensionList,
    async function(extensionId, callback){
      var endpoint = '/restapi/v1.0/account/~/extension/'+ extensionId +'/message-store'
      try {
        var resp = await platform.get(endpoint, {
                   dateFrom: '2018-01-01T00:00:00.000Z',
                   dateTo: '2018-07-31T23:59:59.999Z',
                   messageType: 'Fax'
          })
        var jsonObj = await resp.json()
          if (jsonObj.records.length){
              console.log(extensionId)
              console.log("=========== EXTENSION MESSAGE STORE ===========")
              console.log(JSON.stringify(jsonObj.records
              console.log("+++++++++++++++++++++++++++++++++++++")
              callback("err", null)
          }
      }catch(e){
         console.log(e.message)
      }
    }
  )
}


2 comments
1 |1500 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 What type of admin user profile those this need to be set as?

0 Likes 0 ·

You can try to set the role for the user as "User Admin" If that does not work, set the"Super Admin"

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