Office 365 API get user details

浪子不回头ぞ 提交于 2019-12-08 04:58:44

问题


When I use the url

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

I can get all users in a company, but how can I get more details about a specific user?

Such as in Contacts:

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

There is very little information given in Users (Email, Alias, DisplayName). What if I need to get a user's phone or company name and so on? Are there any other ways?


回答1:


These are actually two different things. The Users node isn't "GET"-able, you have to supply a user ID in the form of an SMTP address, like:

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

The Contacts API is used to access personal contacts only (the contacts a user has stored in their Contacts folder in their mailbox).

It sounds like you want to see users in the organization, in which case you want to use the Azure AD Graph API. The user information for Office 365 is stored in Azure AD.




回答2:


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

You can also retrieve information about a specific contact by using the Id property of the Contact entity.

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

Sample JSON Response: basically what you are looking for!

{
  "@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"
}


来源:https://stackoverflow.com/questions/25530036/office-365-api-get-user-details

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