I have given all required permissions for retrieving user info from Azure active directory like User.Read.All and User.Read but still getting Department and EmployeeId field as NULL
code used:
public Microsoft.Graph.User GetUser(ref GraphServiceClient graphServiceClient, string UserId)
{
return graphServiceClient.Users[UserId].Request().GetAsync().Result;
}
According to the documentation both department
and employeeId
are returned only on $select
.
Use Select
method and specify those two properties. If you need to return more properties, they need to be specified in Select
. Without using Select
, Graph API return only default set of properties.
public Microsoft.Graph.User GetUser(ref GraphServiceClient graphServiceClient, string UserId)
{
return graphServiceClient.Users[UserId]
.Request()
.Select("department,employeeId")
.GetAsync()
.Result;
}
Resources:
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.