stefboe
stefboe

Reputation: 553

How to obtain the AssignedLicenses using Microsoft.Graph Client Library

Is there a working way to read the AssignedLicenses property of a user in the Microsoft Graph Client Library? I tried the following things, but the AssignedLicenses property always returned null allthough there are licenses assigned to the user

// test 1: using "Me"
var lic = client.Me.Request().GetAsync().Result.AssignedLicenses;

// test 2: using the Id of a user
var lic = client.Users["<ID OF THE USER>"].Request().GetAsync().Result.AssignedLicenses;

Upvotes: 2

Views: 2958

Answers (1)

GarethJ
GarethJ

Reputation: 6606

using Select is the correct technique here as you found out, viz Request().Select("assignedLicenses").GetAsync().Result.AssignedLicenses

On the Graph, Select is used BOTH to reduce the set of properties returned and to bring in properties that are not returned by default. We do this in an attempt to keep default packet sizes moderately sized and readable and to keep call performance high by not routing every call to every underlying service necessary to fetch data that most callers don't need.

Upvotes: 3

Related Questions