0
votes

I try to get the list of folders of an Outlook account using the REST API.

Using the MailFolders endpoint, I only get a subset of the folders (for example I'm not getting the Inbox and the Sent Items folders).

If I list all the messages of the account and then for each message try to fetch the ParentFolderId, I get a 404 error for a bunch of them. I'm only able to get the same folders I got from the MailFolders endpoint.

Of course this works for all the other Office 365 accounts I have. And this account doesn't look different from the others.

It's not a matter of folders being renamed because I can see those folders in the Outlook UI.

Of course I correctly paginate the results when both fetching the folders or listing the messages. And again this works fine with all the other Outlook accounts.

I'm using the https://outlook.office.com/api/v2.0/me/MailFolders?%24top=50 endpoint.

Any insights?

Thanks,

Jeremy

Response:

HTTP/1.1 404 Not Found 

Cache-Control: private
Transfer-Encoding: chunked
Content-Type: application/json;odata.metadata=minimal;odata.streaming=true‌​;IEEE754Compatible=f‌​alse;charset=utf-8
Server: Microsoft-IIS/8.5
request-id: e98a3488-3441-474c-8cff-c905f8b9f299 
X-CalculatedFETarget: MWHPR1301CU001.internal.outlook.com
X-BackEndHttpStatus: 404
X-FEProxyInfo: MWHPR1301CA0012.NAMPRD13.PROD.OUTLOOK.COM
X-CalculatedBETarget: MWHPR16MB1661.namprd16.prod.outlook.com
X-BackEndHttpStatus: 404
OData-Version: 4.0
X-AspNet-Version: 4.0.30319
X-DiagInfo: MWHPR16MB1661
X-BEServer: MWHPR16MB1661
X-FEServer: MWHPR1301CA0012
X-Powered-By: ASP.NET
X-FEServer: BY2PR02CA0116
X-MSEdge-Ref: Ref A: 0872CED88164470BA7F119058A1F5CBF Ref B: BAYEDGE0318 Ref C: Thu Apr 27 10:58:51 2017 PST
Date: Thu, 27 Apr 2017 17:58:51 GMT

{
  "error":{
    "code":"ErrorItemNotFound",
    "message":"The specified object was not found in the store."
  }
}
2
Could you post response headers from one of these failed requests?Jason Johnston
Hi Jason, Here are the details of the request.jboga
Body: {"error":{"code":"ErrorItemNotFound","message":"The specified object was not found in the store."}}jboga
Headers: < HTTP/1.1 404 Not Found < Cache-Control: private < Transfer-Encoding: chunked < Content-Type: application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8 < Server: Microsoft-IIS/8.5 < Set-Cookie: exchangecookie=c7fc4cb01bfb41c884b7d6f219181e01; expires=Fri, 27-Apr-2018 17:58:51 GMT; path=/; HttpOnly < request-id: e98a3488-3441-474c-8cff-c905f8b9f299jboga
Headers++:< X-CalculatedFETarget: MWHPR1301CU001.internal.outlook.com < X-BackEndHttpStatus: 404 < X-FEProxyInfo: MWHPR1301CA0012.NAMPRD13.PROD.OUTLOOK.COM < X-CalculatedBETarget: MWHPR16MB1661.namprd16.prod.outlook.com < X-BackEndHttpStatus: 404 < OData-Version: 4.0 < X-AspNet-Version: 4.0.30319 < X-DiagInfo: MWHPR16MB1661 < X-BEServer: MWHPR16MB1661 < X-FEServer: MWHPR1301CA0012 < X-Powered-By: ASP.NET < X-FEServer: BY2PR02CA0116 < X-MSEdge-Ref: Ref A: 0872CED88164470BA7F119058A1F5CBF Ref B: BAYEDGE0318 Ref C: Thu Apr 27 10:58:51 2017 PST < Date: Thu, 27 Apr 2017 17:58:51 GMTjboga

2 Answers

1
votes

I had the same issue. I resolved it by first getting a count of the folders and then made my second request with $top filter to get all my folders. Please see the following code:

$http.get("https://outlook.office.com/api/v2.0/me/MailFolders/$count")
         .then(function(response) {
            //RETRIEVE ALL FOLDERS
            $http.get("https://outlook.office.com/api/v2.0/me/MailFolders?$top="+response.data).then(...)
1
votes

We believe this is caused by the container class property being set incorrectly on the missing folders, likely caused during an IMAP migration (migrating from an IMAP mail system into Office 365). The container class is set to IPF.Imap instead of the expected IPF.Note.

To get these folders to show up, you can change the container class using MFCMapi or EWS Editor. There are instructions on using MFCMapi to do this here:

https://support.microsoft.com/en-us/help/3050475/you-can-t-view-mailbox-folders-on-an-exchange-activesync-or-outlook-client-after-an-imap-migration