MS Graph List Mailfolders not returning all the folders

Graeme Tacon 1 Reputation point

I'm using MS Graph to get all the folders in a mailbox using the following URL:{mailbox}/mailFolders

This returns 10 folders. I then use the URL returned in @odata.nextLink to call the API again, repeating this until there are no more. In total I get 39 folders returned.

But, when I look at the mailbox, it has far more than 39 folders. Why is MS Graph not returning them all - they are all under the same parent folder.

I've tried adding ?$top=100 at the end of the inital URL, but it still only returns 39.

Is this a bug in MS Graph ?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
589 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Novian Winangun 1 Reputation point

    Hi, have you found the answer?

    I am having a similar issue. I am not getting all the sub mailfolders of the parents unless the sub mailfolders were created by the application user that I used to access the inbox.
    I have applied all required permission for the application user.

    • Mail.ReadBasic.All
    • Mail.Read
    • Mail.ReadWrite

    I used the following code:

    var queryOptions = new List<QueryOption>()
    new QueryOption("includeHiddenFolders", "true")
    var TestOCFolders = await graphClient.Users[destination.Email].MailFolders[FolderId].ChildFolders.Request().GetAsync();
    var OCFolders = await graphClient.Users[destination.Email].MailFolders[FolderId].ChildFolders.Request(queryOptions).Top(250).GetAsync();
    No comments