I have authenticated for office 365 outlook using passport js
Now I have access token
So I am looking for to get all folders name with their respective folder Id.
I am using node-outlook library but I am not aware what APIs they have provided get only folders path and folder id.
Thanks
If you only want to get the folder name and folder Id, you can use the following api call:
$http.get("https://outlook.office.com/api/v2.0/me/MailFolders/$select=Id,ChildFolderCount,DisplayName")
Since the above api, only returns main folders, I strongly suggest that you also select ChildFolderCount and add a check in the response, if ChildFolderCount>0, then get the subfolders of the parent by the following call:
$http.get("https://outlook.office.com/api/v2.0/me/MailFolders/"+parent.Id+"/childfolders?$top="+parent.ChildFolderCount)
where parent is the folder with ChildFolderCount>0.
The folder resource has a DisplayName property, so that should get what you want. (Reference).
You can also explore the API over at https://oauthplay.azurewebsites.net/. For example, I did a GET on https://outlook.office.com/api/v2.0/me/mailfolders, and this is an example of the result:
{
"Id": "AQMkAGZjYmY1ZTIwLWI1M2UtNGNkYS05MGQyLTQyMgBjYTliODJhNTIALgAAA6Ii1CwFSf1Ai6F6MypimPkBAGTbcv4AqpNHlH0kubDE5QwAAAIBDwAAAA==",
"DisplayName": "Drafts",
"ParentFolderId": "AQMkAGZjYmY1ZTIwLWI1M2UtNGNkYS05MGQyLTQyMgBjYTliODJhNTIALgAAA6Ii1CwFSf1Ai6F6MypimPkBAGTbcv4AqpNHlH0kubDE5QwAAAIBCAAAAA==",
"ChildFolderCount": 0,
"UnreadItemCount": 2,
"TotalItemCount": 9
}