Microsoft Graph Explorer中返回的不同用户对象 [英] Different User Objects Returning in Microsoft Graph Explorer

查看:147
本文介绍了Microsoft Graph Explorer中返回的不同用户对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Microsoft Graph API.但是,我有一个关于API为用户返回不同值(取决于所调用的端点)的问题/担忧.

I am using the Microsoft Graph API. However, I have a question/concern about the API returning different values for users depending on which endpoint is called.

这是https://graph.microsoft.com/v1.0/me/端点的示例返回值.

Here is an example return value for the https://graph.microsoft.com/v1.0/me/ endpoint.

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity",
    "id": "VALUE GOES HERE",
    "businessPhones": [],
    "displayName": "Lname, Andrew",
    "givenName": "Andrew",
    "jobTitle": "MY TITLE",
    "mail": "andrew.lname@email.com",
    "mobilePhone": null,
    "officeLocation": "123 Business Street",
    "preferredLanguage": null,
    "surname": "Lname",
    "userPrincipalName": "andrew.lname@email.com"
}

调用/me/manager/users/{ID}等时,此格式保持不变.

This format remains the same when calling /me/manager and /users/{ID}, etc.

但是,当我们调用/me/people时,我们得到了一个更大,更完整的用户对象.

However, when we call /me/people we get a much larger and more complete user object.

{
    "id": "ID VALUE HERE",
    "displayName": "LName, Andrew",
    "givenName": "Andrew",
    "surname": "LName",
    "birthday": "",
    "personNotes": "",
    "isFavorite": false,
    "jobTitle": "MY TITLE",
    "companyName": "MY COMPANY NAME",
    "yomiCompany": "",
    "department": "MY DEPARTMENT",
    "officeLocation": "123 Business Street",
    "profession": "",
    "userPrincipalName": "andrew.lname@email.com",
    "imAddress": "sip:andrew.lname@email.com",
    "scoredEmailAddresses": [{
        "address": "andrew.lname@email.com",
        "relevanceScore": 285
    }],
    "phones": [{
        "type": "business",
        "number": "(555) 555-5555"
    }],
    "postalAddresses": [],
    "websites": [],
    "personType": {
        "class": "Person",
        "subclass": "OrganizationUser"
    }
}

首先,有人知道为什么会有区别吗?更重要的是,有人知道我总是可以检索到更强大的用户对象吗?

First, does anyone know why there is a difference and more importantly, does anyone know how I can always retrieve the more robust user object?

推荐答案

发生了几件事:

  1. person user 对象是具有不同属性的不同资源.例如,person可能表示来自Outlook的个人联系人,来自组织GAL的联系人,或者是根据最近的电子邮件或Skype通信构建的.与user相对,该user始终代表组织Active Directory中的用户.

  1. The person and user objects are distinct resources with different properties. A person for example could represent a personal contact from Outlook, a contact from your organization GAL, or constructed from recent email or Skype communications. Contrast this with a user which always represents a User in your organizations Active Directory.

当您检索不带$select参数的user对象时,Microsoft Graph将仅返回user属性的子集.这样做是通过减少默认情况下返回的属性数量来节省带宽的(您可能会为仅检索DisplayName而对/me进行的调用次数感到震惊).从文档:

When you retrieve a user object without a $select parameter, Microsoft Graph will only return a subset of the user properties. This is done to save bandwidth by reducing the number of properties that get returned by default (you'd likely be shocked by how many calls get made to /me just to retrieve DisplayName). From the documentation:

注意:获取用户仅返回默认属性集(businessPhonesdisplayNamegivenNameidjobTitlemailmobilePhoneofficeLocationsurnameuserPrincipalName).使用$select获取用户对象的其他属性和关系.

Note: Getting a user returns a default set of properties only (businessPhones, displayName, givenName, id, jobTitle, mail, mobilePhone, officeLocation, preferredLanguage, surname, userPrincipalName). Use $select to get the other properties and relationships for the user object.

换句话说,当您调用/v1.0/me时,Microsoft Graph会自动将$select=businessPhones,displayName,givenName,id,jobTitle,mail,mobilePhone,officeLocation,preferredLanguage,surname,userPrincipalName附加到您的请求中.如果您指定自己的$select,它将使用您提供的$select.

In other words, when you call /v1.0/me Microsoft Graph is automatically appending $select=businessPhones,displayName,givenName,id,jobTitle,mail,mobilePhone,officeLocation,preferredLanguage,surname,userPrincipalName to your request. If you specify your own $select however it will use the one you provided.

这篇关于Microsoft Graph Explorer中返回的不同用户对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆