javamicrosoft-graph-apioutlook-api

Not able to pull all the contacts exposed via Microsoft graph for outlook account


I have started integrating our code base to use Microsoft graph API, to read the contacts of outlook account as part of a new feature where the user can cherry pick the contacts available so that they can be imported.

For the account I am testing there are a total of 19 contacts available, but when I make the api call, I see only 10 contacts in total ( for sure this is not related to any paging ). Not really sure what is wrong with the contacts which I am not able to pull.

End point - https://graph.microsoft.com/v1.0/me/contacts

Scope - https://graph.microsoft.com/contacts.read

Fields -$select=givenName,middleName,surname,emailAddresses,mobilePhone,homeAddress,homePhones Order By - $orderby=displayName asc

Wondering if any one ran into the issue, where they are not able to pull all the contacts available for the specific account. It would be great if anyone has any pointers for the issue that I am running into.


Solution

  • The /me/contacts endpoint will only return contacts in the mailbox's default Contacts folder.

    In order to retrieve Contacts from other folders, you first need to retrieve the list of available folders using /me/contactFolders. You can then retrieve the Contacts from each of the available folders.

    For example, if we had 3 contact folders: folder1, folder2, and folder3 then you could make three separate calls to retrieve all of the contacts:

    GET /me/contactfolders/folder1/contacts
    GET /me/contactfolders/folder2/contacts
    GET /me/contactfolders/folder3/contacts