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

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

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 Calendar API
Microsoft Graph Applications API
Microsoft Graph Applications API
A Microsoft API that enables you to manage these resources and actions related to applications in Azure Active Directory.
425 questions
No comments
{count} votes

1 answer

Sort by: Most helpful
  1. answered 2023-01-17T07:10:35.3433333+00:00
    Vasil Michev 61,366 Reputation points Microsoft MVP

    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

    No comments