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
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:
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.
I tried to include hidden mail folders and got the response successfully:
https://graph.microsoft.com/v1.0/me/mailFolders?includeHiddenFolders=true
The child folders are also included in the response when you use beta endpoint:
https://graph.microsoft.com/beta/me/mailFolders?includeHiddenFolders=true
Copy the Mail folder ID and pass in the below query:
Now I tried to list the child folders under the mail folder:
https://graph.microsoft.com/v1.0/me/mailFolders/ID/childFolders
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
If still the issue persists, try using v1.0 endpoint.
Mail.Read
API permission.Reference: