0

When login into the outlook office 365 interface to manage his/her contacts, a user would click on the blue icon with nine squares at the top left of the UI and select the "Contacts" tile. On the left, the user would see the folders "My contacts", "Directory" and "Groups". At least, this is what I see.

I managed to use the REST API of office 365 to query the contacts listed in "My contacts" as follow:

GET outlook.office365.com/api/v1.0/me/contacts?$top=200

And I was happy. But I have been asked to import the contacts listed in the "Directory" folder.

So I browsed a bit in the doc and saw I could query specific contact folders doing:

GET https://outlook.office.com/api/{version}/me/contactfolders/{contact_folder_id}/contacts

The problem is that I cannot find the {contact_folder_id} corresponding to "Directory". A query to endpoint:

GET https://outlook.office.com/api/{version}/me/contactfolders

returns an empty array, I do not even see the "My contacts" folder.

Any idea of how I could get those? I am secretly fearing that I have to talk with the global Graph API to get those AzureAD contacts, which would mean I should get a new token, complicating a bit the code. If there is a simpler way to do so, it would be very helpful!

Jason Johnston
  • 17,194
  • 2
  • 20
  • 34
qnilab
  • 380
  • 3
  • 18

1 Answers1

1

The Outlook API can only access Outlook contacts, which are the contacts a user has stored in their personal contact folders. For directory contacts, you require access to the directory, which as you mentioned, are in Azure AD. You do need to use Graph API to access them.

You mentioned added complexity with token management. One thing you might consider is using the unified API, which gives access to both Azure AD and Outlook data using one token. It's currently in preview, and there's a getting started here: https://msdn.microsoft.com/en-us/office/office365/howto/get-started-with-office-365-unified-api

Jason Johnston
  • 17,194
  • 2
  • 20
  • 34
  • Thanks for confirming my doubts Jason. I tried using the unified API a few month ago, but somehow it did not have all the functionalities I was looking for (calendar and contacts management) or was asking to require some admin permissions (which we would like to avoid to have an easier adoption of our app) and I fell back on the office365 API. It might be time to give the unified API a new try, thanks for pointing that out! – qnilab Aug 25 '15 at 17:02
  • Jason is correct. The unified API will give you a way to do this through one endpoint. However currently personal contacts are not exposed through the unified API. This is something we will be addressing soon. What things were missing from calendar (contacts is definitely not there)? – Dan Kershaw - MSFT Aug 27 '15 at 17:47
  • Hi Dan. Actually, I did not remember well: nothing was missing but the access to contacts required to ask for admin permissions, which we would like to avoid. I reformulated my question [here](http://stackoverflow.com/questions/32280829/how-does-apple-mail-gets-access-to-my-azuread-contacts). If you have any clue on the matter, I would greatly appreciate it! – qnilab Aug 28 '15 at 22:58