azuremicrosoft-graph-apimicrosoft-graph-sdks

Unable to Retrieve Hidden MailFolders (isHidden = true) with Microsoft Graph API


I am trying to retrieve mail folders, including those where isHidden = true, using the Microsoft Graph API. According to the official Microsoft documentation, I should be able to use the following endpoint to include hidden folders:

https://graph.microsoft.com/beta/me/mailFolders?includeHiddenFolders=true

https://learn.microsoft.com/en-us/graph/api/user-list-mailfolders?view=graph-rest-beta&tabs=http#request-1

However, when I test this endpoint in the Graph Explorer, it only returns folders with isHidden = false.

To narrow down the scope, I want to retrieve all childFolders under msgfolderroot, including the hidden ones. I used the following endpoint:

https://graph.microsoft.com/beta/me/mailFolders/msgfolderroot/childfolders?includeHiddenFolders=true&$top=100

This also only returns 12 folders where isHidden = false, even though I know for a fact that the msgfolderroot contains 21 child folders in total, some of which have isHidden = true.

What I Have Tried:

  1. Verified the msgfolderroot structure through another API call.
  2. Ensured the includeHiddenFolders=true parameter is included in the request.
  3. Tested with both /v1.0/ and /beta/ versions of the Graph API.

Expected Behavior: The response should include all child folders under msgfolderroot, including those with isHidden = true.

Actual Behavior: The response only includes folders with isHidden = false.

Question: How can I retrieve all folders, including the hidden ones (isHidden = true), under msgfolderroot using the Microsoft Graph API? Is there a specific parameter or approach I’m missing, or is this a known issue/limitation of the API?

Thank you in advance for your help and insights! Any guidance would be greatly appreciated.


Solution

  • I tried to include hidden mail folders and got the response successfully:

    https://graph.microsoft.com/v1.0/me/mailFolders?includeHiddenFolders=true
    

    enter image description here

    The child folders are also included in the response when you use beta endpoint:

    https://graph.microsoft.com/beta/me/mailFolders?includeHiddenFolders=true
    

    enter image description here

    Copy the Mail folder ID and pass in the below query:

    enter image description here

    Now I tried to list the child folders under the mail folder:

    https://graph.microsoft.com/v1.0/me/mailFolders/ID/childFolders
    

    enter image description here

    To list the hidden child folders by passing the ID, use the below query:

    https://graph.microsoft.com/v1.0/me/mailFolders/ID/childFolders?includeHiddenFolders=true
    

    enter image description here

    If still the issue persists, try using v1.0 endpoint.

    Reference:

    List mailFolders - Microsoft Graph v1.0 | Microsoft