0
votes

Note: Same flow is working for Office 365 license.

Exchange Setup information: We have a hybrid environment, with primary exchange server being on-premise and are archiving user mails boxes in exchange online.

Licensing: Exchange Online Archiving

Scenario: We are using Office 365 rest apis. I have used Global admin authorization and stored the resulting refresh token in secure location. Using refresh token, I fetch access token. This access token is then used to fetch User's Mail endpoint.

Then to fetch users mail folder, I create new access_token of client_credentials type and then query for folder listing on the above endpoint.

Below is the detailed request/response. user_name and access_token has been intentionally removed for privacy reasons.

** REQUEST START (Sat Apr 23 07:40:28 2016) **
REQUEST: GET https://outlook.office365.com/api/v1.0/users('<user_name>')/folders/?$top=100
Accept-Encoding: gzip, deflate
accept: application/json
User-Agent: python-requests/2.4.1 CPython/2.7.8 Linux/3.13.0-83-generic
Connection: keep-alive
content-type: application/json
Authorization: Bearer <access_token>
None
* * * *
RESPONSE (404)
x-calculatedbetarget: AM2PR05MB1089.eurprd05.prod.outlook.com
x-powered-by: ASP.NET
transfer-encoding: chunked
request-id: 8c9ac8a6-8fe7-46f6-8dcc-1fff8b1ac8ac
x-aspnet-version: 4.0.30319
server: Microsoft-IIS/8.0
cache-control: private
x-beserver: AM2PR05MB1089
x-diaginfo: AM2PR05MB1089
x-feserver: BN1PR08CA0019
set-cookie: exchangecookie=309073c961cb44798302c8eb2fee0188; expires=Sun, 23-Apr-2017 07:40:28 GMT; path=/; HttpOnly
date: Sat, 23 Apr 2016 07:40:28 GMT
odata-version: 4.0
content-type: application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
x-backendhttpstatus: 404
{"error":{"code":"ErrorFolderNotFound","message":"The specified folder could not be found in the store."}}

My question:

  1. Are office 365 rest APIs not supported for exchange online archiving license? If they are supported, then why I am getting 404 error with message "specified folder not found"?
1

1 Answers

0
votes

As I tested, if the user does not have a primary mailbox on Exchange Online, you will get the 404 error. For example, a user does not exists in Azure AD or a user exists in Azure AD, but does not have a Exchange Online licence (Compare Exchange Online plans)

In your case, the user licence is "Exchange Online Archiving", which is a cloud-based, enterprise-class archiving solution that helps you to solve archiving, compliance, regulatory, and eDiscovery challenges. But it does not provide user a primary mailbox on Exchange Online, that's why the user will get 404 error when trying to find the primary mailbox.

Update#1:

I assume the hybrid environment is as following: Exchange on-premise + Exchange Online (Exchange Online Plan 1 or 2 + Exchange Online Archiving) .

Some users mailbox are fully on Exchange online, but others's mailbox are on the on-premise Exchange Server (please correct me if I have any misunderstanding).

Currently, the Office 365 API does not support accessing the achieve mailboxes.

For the users whose primary mailboxes are on the on-premise Exchange Server. Since the Office 365 API applies to the Exchange Online but not applies to Exchange on-premise, you are not able to use the Office 365 API on these users. enter image description here

For the users whose primary mailbox are on the Exchange online (Exchange Online Plan 1 or 2 users), you will be able to user the Office 365 API to access the mailbox.

To access mailbox in on-premise Exchange Server, you can consider using the EWS API.