Skip to main content

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?

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)
}
}
)
}



Reply