Bassie
Bassie

Reputation: 10400

How to retrieve all user properties with MS Graph SDK

Using the Microsoft Graph quick start guide, I can get my user object with

var one = await graphClient.Me.Request().GetAsync();

But it only includes values for these properties

BusinessPhones       
DisplayName          
GivenName            
Id                   
JobTitle             
Mail                 
OfficeLocation       
Surname              
UserPrincipalName    

Where the rest are just null. However, I expect to see some values in, for example AboutMe.

I can retrieve that value specifically with

var one = await graphClient.Me.Request().Select("aboutme").GetAsync();

But is there a way to get all properties?

I tried

var one = await graphClient.Me.Request().Select("").GetAsync();
var one = await graphClient.Me.Request().Select("*").GetAsync();

But that doesn't return all properties.

Upvotes: 1

Views: 3644

Answers (1)

Karlheinz Reinhardt
Karlheinz Reinhardt

Reputation: 1075

It seems that this is not yet? implemented.

The Documentations for the select parameter states:

In v1.0, some Azure AD resources that derive from directoryObject, like user and group, return a limited, default subset of properties on reads. For these resources, you must use $select to return properties outside of the default set.

https://developer.microsoft.com/en-us/graph/docs/concepts/query_parameters#select-parameter

This seems to be the reason why a select=* is returning only some directoryObject-properties, as the user-object is derived from the directoryObject.

To access all properties you would need to manually define them in your select-query or alternatively you could adjust the default set for the server to return all properies (not sure if you can define this in the online application settings though).

Upvotes: 2

Related Questions