Graph API: MailboxNotEnabledForRESTAPI - The mailbox is either inactive, soft-deleted, or is hosted on-premise

Sanket Khot 51 Reputation points
2023-01-17T06:12:13.23+00:00

I have two separate Microsoft business accounts, one named Account A and the other named Account B.
I am currently utilising Account A to register my application and I am making API calls such as users, profile information, calendars, and events.

For testing purposes, I have invited a user from Account B and that user has been added as a guest user in Account A. I am able to retrieve basic information of the guest user using the API '/me' and also by using the API '/users/{user_id}'.

However, I am encountering the error "MailboxNotEnabledForRESTAPI - The mailbox is either inactive, soft-deleted or is hosted on-premise" when I try to retrieve the calendar or events of the guest user by using the API calls '/users/{user_id}/calendars' or
'/users/{user_id}/events'.

I got the following permissions for the application
Calendars.Read
Calendars.Read.Shared
Calendars.ReadWrite
Contacts.Read
Contacts.ReadWrite
Directory.Read.All
Directory.ReadWrite.All
email
Mail.Read
Mail.ReadWrite
Mail.Send
MailboxSettings.ReadWrite
offline_access
openid
People.Read
profile
User.Read
User.Read.All
User.ReadBasic.All
User.ReadWrite.All

I can log in to outlook and see emails which means the mailbox is active.
it's not soft deleted.
and if I go to the user in account B in the admin centre and click on the name I can see the following things in the mail tab and OneDrive tab which confirms that it is on the cloud

User's image

User's image

How Can I resolve this error ??

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,491 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Vasil Michev 94,521 Reputation points MVP
    2023-01-17T07:10:35.3433333+00:00

    Guest users do not get a mailbox within resource tenants, only in their "home" tenant. If you want to use the same application to access the events from mailboxes in different tenants, you need to register the app as multi-tenant one, and have each tenant/user consent to the required scopes. Read here: https://learn.microsoft.com/en-us/azure/active-directory/develop/howto-convert-app-to-be-multi-tenant

    0 comments No comments