Reputation: 51
I want to get manager relation for all users and this can easily be done with https://graph.microsoft.com/beta/users?expand=manager.
But I get all data on all users and all data for each manager, which is way too much! I want to limit my result set to only return id and displayName for user and only id on the manager relation.
https://graph.microsoft.com/beta/users?select=id,displayName&expand=manager(select=id)
This is not working and I get this error:
Term 'manager($select=id)' is not valid in a $select or $expand expression.
Any help is much appreciated.
Upvotes: 5
Views: 3686
Reputation: 4357
Here is graph API documentation that shows how to expand the entire management chain and return selected fields. Slight caveat that it works on the documentation page but it doesn't return the expected results at https://developer.microsoft.com/en-us/graph/graph-explorer.
https://graph.microsoft.com/v1.0/me?$expand=manager($levels=max;$select=id,displayName)&$select=id,displayName&$count=true
Link to graph API User List Manager:
Upvotes: 1
Reputation: 316
Sad to say, I was looking for this as well - it seems that this is not supported:
https://developer.microsoft.com/en-us/graph/docs/concepts/query_parameters#expand-parameter
Not all resources or relationships support using $select on expanded items.
I think this means you cant use select on manager expand.
I would take it further even and say you cannot use select on the users query itself, since there is no way to include the expanded "manager" in the select, even with all its properties. Once you set a select statement your expanded manager property will be gone.
There are two choices at this point:
I think depending on how much data you are planning to get (number of users, properties you need) you should choose the best way forward for you.
Upvotes: 2