error occured "Access is denied. Check credentials and try again. The store ID provided isn’t an ID of an item." when trying to access the mail item using graph API from outlook add-in on mobile (IOS).

Diluka Hewage 31 Reputation points
2023-03-14T04:39:13.8933333+00:00

Hi all,

I am developing an outlook add-in that supports OWA, desktop, IOS and android. I am using the following graph API to get the mail item.

[/v1.0/users/testuser@testdev.onmicrosoft.com/messages/${mailItemId}]

This works on almost all the tenants that I have tested but there is one particular tenant that recently migrated mailbox to exchange online from on-premises exchange. That tenant is only having the following issue.

When I am running the add-in on email on outlook desktop, this graph API call works fine but when I run the add-in on IOS device on the same email I ran on the desktop then this graph call fails and gives the following error.

Code: ErrorAccessDenied

Message: Access is denied. Check credentials and try again. The store ID provided isn’t an ID of an item.

User's image

When add-in runs on OWA or desktop I convert mail item id to REST-formatted using Office.context.mailbox.convertToRestId method before making the graph API call but in IOS or Android environment I don’t convert the mail item id because, In Outlook Mobile, the value returned by Office.context.mailbox.item.itemId is a REST-formatted ID and can be used as-is. I am doing that conversion as follows.

function getItemRestId() {
  if (Office.context.mailbox.diagnostics.hostName === 'OutlookIOS'  ||     Office.context.mailbox.diagnostics.hostName === 'OutlookAndroid') {
    // itemId is already REST-formatted.
    return Office.context.mailbox.item.itemId;
  } else {
    // Convert to an item ID for API v2.0.
    return Office.context.mailbox.convertToRestId(
      Office.context.mailbox.item.itemId,
      Office.MailboxEnums.RestVersion.v2_0
    );
  }
}

The following one is the graph call that is made by IOS device, and it doesn’t work.

 

GET [/v1.0/users/diluka@testdev.onmicrosoft.com/messages/AAkALgAAAAAAHYQDEapmEc2byACqAC-EWg0ASnkxz0CXRky-Oh3HtJRmdAAAmwAojQAA]

 

The following one is the graph call that is made by outlook desktop, and it works fine.

 

GET [/v1.0/users/Diluka@testdev.onmicrosoft.com/messages/AAMkADRkNTM0MWZkLTc2NTItNGI2Ny1iOWZiLTFiNDM5ZmIzOTM5ZgBGAAAAAAAftAEVwxU3RaepYBocX1JuBwDnWRi5bPz9Q7jQYCDNVSj8AAAAAAEMAABKeTHPQJdGTL86Hce0lGZ0AAChIRN0AAA=]

 

**** These both graph calls referring the same email ****

 

Can anyone help with this issue?

JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
875 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
3,513 questions
0 comments No comments
{count} vote