To fetch only active folders not deleted from mailfolders

Ajeet Singh 1 Reputation point
2022-01-28T09:03:51.46+00:00

Hi,

I am using MS Graph endpoint to retrieve the folders in Outlook as mentioned below:

https://graph.microsoft.com/v1.0/users/me/mailFolders

but I am getting even deleted folders as well. If folder is deleted and exists in Trash/Deleted Items folders or folder is deleted permanently even then we are getting such folders in the response.

Is there any way, we can differentiate deleted folders in response or we can retrieve only active folders instead of deleted folders (both exists in Trash or permanently deleted)

Thanks in advance for your help.

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,524 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Glen Scales 4,431 Reputation points
    2022-01-30T23:35:14.38+00:00

    Sounds like your using the beta endpoint rather then production eg

    https://graph.microsoft.com/beta/users/me/mailFolders

    rather then

    https://graph.microsoft.com/v1.0/users/me/mailFolders

    the beta does a full traversal but you shouldn't be using that in production apps as it subject to change in the future, with the production endpoint at the moment it just does a shallow traversal of whatever folder your searching so you would have to do childFolder traversal https://learn.microsoft.com/en-us/graph/api/mailfolder-list-childfolders?view=graph-rest-1.0&tabs=http of every folder you want to retrieve subfolders for so for in the case of Deleted Items folder you just exclude that.

    0 comments No comments