Hello @Mark Benson
Thanks for reaching out!
You can list down the childFolders of a MailFolder using List ChildFolders endpoint. Endpoint: GET /me/mailFolders/{id}/childFolders
Using above endpoint, you'll get the ID of the childFolder in response and post that, you can replace the parentMailfolderID with the childFolderID in endpoint, which will further list the children of that childFolder. More precisely, you need to make multiple calls to get into the last child folder.
Please find the detailed steps below:
GET https://graph.microsoft.com/v1.0/me/mailFolders
- will list all the mailFolders
GET https://graph.microsoft.com/v1.0/me/mailFolders/{mailFolderID}
- get the MailFolder details
GET https://graph.microsoft.com/v1.0/me/mailFolders/{mailFolderID}/childFolders
- List childFolders of MailFolder
GET https://graph.microsoft.com/v1.0/me/mailFolders/{childFolderID}/childFolders
- mailFolderID replaced with childFolderID (Repeat until you reach the last childFolder)
Now use the last ChildFolderID as a destinationID in the request body of Move Messages Endpoint
Endpoint:
POST https://graph.microsoft.com/v1.0/me/messages/{message-id}/move
Content-type: application/json
{
"destinationId": "ChildFolderID"
}
Hope this helps.
If the answer is helpful, please click Accept Answer and kindly upvote. If you have any further questions about this answer, please click Comment.