Search code examples
office365apioutlook-restapioffice365-restapi

Discard hidden folders with Outlook REST Api


When retrieving folders list with Outlook REST API (beta endpoint)

https://outlook.office365.com/api/beta/me/MailFolders

I get the complete list of folders. But I also get some hidden/ignored folders that are not displayed in usual Outlook clients. I would like to ignore such folders as well.

I tried to forge a request using SingleExtendedProperty and PigTagAttributeHidden

https://outlook.office365.com/api/beta/me/MailFolders?$select=Id,DisplayName,ParentFolderId,ChildFolderCount,UnreadItemCount,TotalItemCount,SingleValueExtendedProperties&$expand=SingleValueExtendedProperties($filter=(PropertyId eq 'Boolean 0x10F4'))

In the results this property is always marked as false even for these "ignored" folders.

Is there another way or fix to achieve this?


Solution

  • I went through the folders reported, and none of them were hidden. Basically they fell into two categories:

    • System folders like Sync Issues and Conflicts. These aren't hidden, but OWA doesn't show them in it's folder view. OWA handles these specially. The suggestion for a REST app that wants to also handle these specially and not show them is to check the WellKnownName property. All of these have a constant value for that property, so they can be selectively filtered.
    • Add-in folders. These were created by a module extension add-in. They actually reside in a folder structure like:

      /WebExtAddIns (Hidden)
          |__/{GUID id of addin} (Hidden)
              |__/{Name of module extension tab} (Visible)
      

      The REST API includes the {Name of module extension tab} folder because it's marked visible, even though it's parent folder is hidden. I've reported this to our developers and we are investigating improving this scenario. In the meantime, you can filter these out by making sure that the ParentFolderId matches either the Id of another folder in the folder results OR the ParentFolderId of the Inbox folder.