1
votes

We are trying to get user profiles of our company contacts through beta/me/people, but it seems that we can’t get all contacts, even if we have the id of the user from the /v1.0/users API.

The number of users we get is different depending on which account is logged in, too.

The documentation states that it's a ranked list, but should I be able to get one by id?

Can anyone help us on why this is? Is there any way that we can get for example, the phone number for each user without the admin having to change permissions?

1

1 Answers

4
votes

The /beta/me/people endpoint returns a list of contacts related to the current user. This "relation" is based on things like emails, phone calls, and documents. This is why it changes depending on which user is logged in. In my case for example, my manager shows up at the top of the result but folks within the company I've never interacted with do not.

If you're looking for a pure list of contacts for a given user (i.e. their Contacts from Outlook) you can use the /me/contacts endpoint. This returns a list of Contact records from the current user's default Contacts folder in Outlook/Exchange.

If you're looking for the profile information for internal people (i.e. user accounts), this can be done using the /users endpoint. This will return all of the users within your organization.

If you're looking to get the profile information for a single user account, this can be retrieved using the /users/{id | userPrincipalName}. Generally I recommend using userPrincipalName as it does make debugging and reviewing logs a little more human readable.

If you're looking to retrieve a single Contact from a user's Contacts folder, this can be done using the $filter query parameter. For example: me/contacts?$filter=emailAddresses/any(a:a/address eq '@domain.com').

If you're looking to grab a single person from the /me/people endpoint, you can do that by simply adding the id for that user to the path: /me/people/{id}

Please note that using the beta endpoint can result in unexpected behavior. These endpoints are available for testing but are absolutely not appropriate for production workloads.