I'm trying to get a list of ConsumedUnits from the Microsoft Graph API using C# following this article:
https://docs.microsoft.com/en-us/graph/api/subscribedsku-list?view=graph-rest-1.0&tabs=csharp
I'm able to get the expected response when I hit the Graph Explorer, but try to hit it using the SDK/C# and console the response all it returns is
Microsoft.Graph.GraphServiceSubscribedSkusCollectionPage
If anyone has an example how to pull ConsumedUnits from this endpoint through the SDK I'd love to see it!
CodePudding user response:
GraphServiceSubscribedSkusCollectionPage
has two properties:
CurrentPage
which is an IList<SubscribedSku>
and
NextPageRequest
which is an IGraphServiceSubscribedSkusCollectionRequest
used to get to the next page of items, if another page exists. This value will be null if there is not a next page.
Example how to get all items:
var items = new List<SubscribedSku>();
var subscribedSkus = await graphClient.SubscribedSkus
.Request()
.GetAsync();
items.AddRange(subscribedSkus.CurrentPage);
while (subscribedSkus.NextPageRequest != null)
{
subscribedSkus = await subscribedSkus.NextPageRequest.GetAsync();
items.AddRange(subscribedSkus.CurrentPage);
}
Resources: