Office 365 API获取用户详细信息

时间:2014-08-27 14:35:35

标签: office365

当我使用网址

https://outlook.office365.com/EWS/OData/Users

我可以获得公司中的所有用户,但是如何获得有关特定用户的更多详细信息?

例如Contacts

https://outlook.office365.com/EWS/OData/Me/Contacts

UsersEmailAliasDisplayName)中提供的信息非常少。如果我需要获得用户的电话或公司名称等,该怎么办?还有其他方法吗?

2 个答案:

答案 0 :(得分:3)

这实际上是两件不同的事情。 “用户”节点不是“GET”,您必须以SMTP地址的形式提供用户ID,如:

GET https://outlook.office365.com/ews/odata/Users("sadie@contoso.com")

Contacts API仅用于访问个人联系人(用户已存储在其邮箱的“联系人”文件夹中的联系人)。

听起来您希望在组织中看到用户,在这种情况下您要使用Azure AD Graph API。 Office 365的用户信息存储在Azure AD中。

答案 1 :(得分:1)

见这里:http://msdn.microsoft.com/en-us/library/office/dn792115%28v=office.15%29.aspx#sectionSection2

  

您还可以使用检索有关特定联系人的信息   Contact实体的Id属性。

     

获取https://outlook.office365.com/ews/odata/Me/Contacts(contactId)

示例JSON响应:基本上就是您要找的东西!

{
  "@odata.id": "https://outlook.office365.com/EWS/OData/Users('sadie@contoso.com')/Contacts('AAMkADA5...')",
  "@odata.etag": "W/\"EQAAABYAAACjVbBbHnDNQZzaeCbB94zAAABkh+ph\"",
  "@odata.editLink": "https://outlook.office365.com/EWS/OData/Users('sadie@contoso.com')/Contacts('AAMkADA5...')",
  "Id": "AAMkADA5...",
  "ChangeKey": "EQAAABYAAACjVbBbHnDNQZzaeCbB94zAAABkh+ph",
  "ClassName": "IPM.Contact",
  "Subject": "Alex Darrow",
  "BodyPreview": "",
  "Body": {
    "ContentType": "Text",
    "Content": ""
  },
  "Importance": "Normal",
  "Categories": [],
  "HasAttachments": false,
  "ParentFolderId": "AAMkADA5...",
  "Birthday": null,
  "FileAs": "Darrow, Alex",
  "DisplayName": "Alex Darrow",
  "GivenName": "Alex",
  "Initials": null,
  "MiddleName": null,
  "NickName": null,
  "Surname": "Darrow",
  "Title": null,
  "Generation": null,
  "EmailAddress1": "alex@alpineskihouse.com",
  "ImAddress1": null,
  "ImAddress2": null,
  "ImAddress3": null,
  "JobTitle": null,
  "CompanyName": null,
  "Department": null,
  "OfficeLocation": null,
  "Profession": null,
  "BusinessHomePage": null,
  "AssistantName": null,
  "Manager": null,
  "HomePhone1": null,
  "HomePhone2": null,
  "BusinessPhone1": null,
  "BusinessPhone2": null,
  "MobilePhone1": null,
  "OtherPhone": null,
  "DateTimeCreated": "2014-07-01T16:24:09Z",
  "LastModifiedTime": "2014-07-01T16:24:09Z",
  "Attachments@odata.navigationLink": "https://outlook.office365.com/EWS/OData/Users('sadie@contoso.com')/Contacts('AAMkADA5...')/Attachments"
}