Graph API - List Users with mailboxSettings

Quentin DREYER 21 Reputation points
2022-12-19T13:07:18.587+00:00

Hello,

I'm trying to list users mailboxSettings using the Graph API.

The following request (without mailboxSettings) works : https://graph.microsoft.com/beta/users?$select=id, but the one with mailboxSettings fails : https://graph.microsoft.com/beta/users?$select=id,mailboxSettings with the error :

   {  
       "error": {  
           "code": "ExplicitTargetMailboxIdShouldNotBeNullOrWhiteSpace",  
           "message": "The Id is invalid.",  
           "innerError": {  
               "date": "2022-12-19T13:05:51",  
               "request-id": "6cf5161c-13da-401c-850e-0149376aaeea",  
               "client-request-id": "1dd1d236-5f16-c3b7-839a-484687d3332b"  
           }  
       }  
   }  

Any ideas?
Thanks in advance!

Quentin

Exchange Online
Exchange Online
A Microsoft email and calendaring hosted service.
6,171 questions
Microsoft Security Microsoft Graph
{count} votes

Accepted answer
  1. Srinivasa Rao Darna 6,761 Reputation points Microsoft External Staff
    2022-12-19T15:29:07.23+00:00

    Hello @Quentin DREYER ,

    As per documentation user-mailboxSettings can be used only for the primary mailbox of the signed-in user. You can get or update settings.

    GET /users/{id}?$select=id,mailboxSettings  
    

    Hope this helps.
    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".


2 additional answers

Sort by: Most helpful
  1. Vasil Michev 119.5K Reputation points MVP Volunteer Moderator
    2022-12-19T14:49:03.633+00:00

    You can only query mailboxSettings one user at a time, afaik. So this would work:

    GET https://graph.microsoft.com/beta/users/{userId}?$select=id,mailboxSettings  
    
    2 people found this answer helpful.

  2. Zehui Yao_MSFT 5,876 Reputation points
    2022-12-22T08:41:32.277+00:00

    Hi @Quentin DREYER , the error "The mailbox is either inactive, soft-deleted, or is hosted on-premise" may occur because the user you are accessing (the user referred to by the user-id) lacks a valid M365 license. So please check if the user is assigned the license first. And to read the mailboxsetting, you need to add MailboxSettings.Read permission. Hope can help you. Best Wishes.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.