Properties null when using /users but not when using /me/contacts

孤街醉人 提交于 2020-01-02 12:00:23

问题


When getting contacts from https://graph.microsoft.com/v1.0/me/contacts I get all properties for a user, ex:

{
  displayName: 'Joe Joeson',
  jobTitle: 'Administrator',
  department: 'HK',
  mobilePhone: '09823987234',
  businessPhones: '8934598743',
  mail: 'joe@mail.com',
}

But when I get all users of the organization (with https://graph.microsoft.com/v1.0/users?$select=displayName,jobTitle,department,mobilePhone,businessPhones,mail,userType) the same contact doesnt get some properties, ex:

{
  displayName: 'Joe Joeson',
  jobTitle: null,
  department: null,
  mobilePhone: null,
  businessPhones: null,
  mail: 'joe@mail.com',
}

Why? Its the same contact? Or am I missing something? Should I get all contacts from the organization in another way?

I have confirmed that all properties are set in https://portal.azure.com


回答1:


The /contacts and /users endpoints return two different entities. A contact entity represents an Outlook Contact from the current user's Exchange mailbox whereas the a user entity represents an User directory object from the tenant's Active Directory instance.

The reason you're seeing two different results is because you're returning two different entities. The first is the Joe Joeson contact from your Outlook/Exchange mailbox and the second is the Joe Joeson user from Active Directory.

The reason you're seeing less information from /users is due to your requesting the Read all users' basic profiles (aka User.ReadBasic.All) scope. This scope can only see a limited number of properties from a user resource: displayName, givenName, surname, photo, and mail.



来源:https://stackoverflow.com/questions/47093399/properties-null-when-using-users-but-not-when-using-me-contacts

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!