Im still battleing with trying to pull down the details of the logged in (Outlook) user within the add in im developing.
I have exploered the EWS service but, as far as I cant tell, the functions I need are not available so I have started looking at the Outlook REST API.
I can get very basic user details with the following call:
function sendFindPersonRequest() {
//get auth token for Graph
Office.context.mailbox.getCallbackTokenAsync({ isRest: true }, function (result) {
if (result.status === "succeeded") {
var accessToken = result.value;
console.log('REST Access Token : ' + accessToken);
// Use the access token.
getCurrentItem(accessToken);
} else {
// Handle the error.
}
});}
function getCurrentItem(accessToken) {
// Construct the REST URL to the current item.
// Details for formatting the URL can be found at
// https://learn.microsoft.com/previous-versions/office/office-365-api/api/version-2.0/mail-rest-operations#get-messages.
var getMessageUrl = Office.context.mailbox.restUrl +
'/v2.0/me/';
$.ajax({
url: getMessageUrl,
dataType: 'json',
headers: { 'Authorization': 'Bearer ' + accessToken }
}).done(function (item) {
// Message is passed in `item`.
var subject = item.displayName;
console.log('item subject: ' + subject);
}).fail(function (error) {
// Handle error.
});
}
But this doesnt pass any more than Alias, DisplayName and Emailaddress.
@odata.context: "https://outlook.office365.com/api/v2.0/$metadata#Me"
@odata.id: "https://outlook.office365.com/api/v2.0/Users('')"
Alias: "Joe.Bloggs"
DisplayName: ""
EmailAddress: "[email protected]"
Id: "baf52ae4-............"
MailboxGuid: "257f3fe1-6.............."
Im looking to get extendeddetails such as Jobtitle, OfficeAddress etc (which are standard AD fields).
I have looked at the GetUser method as well but that returns the same. I really dont want to go down Graph route and it feels that I am missing something as really expect those other fields to be there.
Has any one else used this to better affect?
Thanks
I didn't see where we can create extensions for a user based on Office 365 Data Extensions and Outlook Extended Properties.
And Microsoft.OutlookServices.User also doesn't have such properties as Jobtitle, OfficeAddress etc.
When I tried to use the OData $select
query parameter like:
https://outlook.office365.com/api/v2.0/me?$select=DisplayName,Jobtitle,OfficeAddress
It will give an error: "Could not find a property named 'Jobtitle' on type 'Microsoft.OutlookServices.User'."
I'm afraid that what you want is not available in Outlook REST API. You should use Microsoft Graph API or AAD Graph API instead.
Update:
We can use GET https://outlook.office365.com/api/v2.0/me/people?$search=""
to find the person's information.