You can see that I've made three test contacts in the UI accessible here: https://outlook.live.com/people/
When I call the List Contacts API ( https://graph.microsoft.com/beta/me/contacts?$orderby=createdDateTime desc&$top=50
), I get a list of contacts that is much more extensive than the list visible in the UI. These contacts appear to be anyone that has emailed me or anyone that I've emailed.
If I want to poll against the GET /me/contacts
endpoint to get some data whenever I make a new contact, I'll end up getting notified every time someone new sends me an email or every time I send someone new an email (even if I didn't manually create the contact).
Is this intentional? If so, are there any filters I could add to specify that I don't want to get contacts that were not manually created by me? Looking over the JSON representation of a contact , I don't see anything I can filter on.
My only thought is that I notice that the contacts made for me exist in a folder that is not returned in the contactFolders API endpoint. I could theoretically make a call to that endpoint and take the list of contacts returned and check if the parentFolderId
exists in there. If it does, presumably that's because we created a contact and if not then it's made for us. That feels terribly hacky, though.
Thanks for the help!
This is an issue with the Microsoft Graph Beta APIs. Switching to the v1.0 of the Graph REST APIs resolved this.
It seems Outlook automatically adds every email address that had been in contact with the user as a hidden contact in a hidden folder.
The GET beta/me/contacts
endpoint (unlike the v1.0
one) returns all contacts from all folders, so it also includes this hidden folder.
There are two ways to get the expected list of contacts:
Option 1 - get all contacts, and then filter:
GET /beta/me/contactFolders
to obtain a list of "real" folders (this endpoint does not return that hidden folder) GET /beta/me/contacts
to get all contacts in the account parentFolderId
- to keep only contacts in one of the folders returned at step 1Option 2 - get contacts by folder:
GET /beta/me/contactFolders
to obtain a list of "real" folders (this endpoint does not return that hidden folder) GET /beta/me/contactFolders/{folder-id}/contacts
and aggregate the returned contact listsHope this helps.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.