Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get extended additional properties with graphclient

I am trying to receive a user from Microsoft Graph using the graphclient. the last property is an extended property that has been replicated across from on premise AD and i dont know how to reference it?

i can select the property using a normal url format Graph request using Graph Explorer so i know it is there, just not sure of the syntax using the graphclient?

        var user = await graphClient.Me.Request()
            .Select(u => new {
                u.DisplayName,
                u.Mail,
                u.UserPrincipalName,
                u.Department,
                u.OnPremisesSamAccountName,
                u.OfficeLocation,
                u.GivenName,
                u.Surname,
                u.JobTitle,
                 u.??["extension_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_PersonID"]
            })
            .GetAsync();
like image 932
user900566 Avatar asked Nov 16 '25 10:11

user900566


1 Answers

Please try the below code

try
        {


            List<Option> requestOptions = new ArrayList<Option>();

            requestOptions.Add(new QueryOption("$select", "extension_xxx_FavouriteSeason,DisplayName,Mail,UserPrincipalName"));



            var user = await graphClient.Users["xxxx"].Request(requestOptions)
     
            .GetAsync();



            Console.WriteLine(JsonConvert.SerializeObject(user));
              
        }
   catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
like image 147
Sruthi J Avatar answered Nov 19 '25 10:11

Sruthi J



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!