简体   繁体   中英

Microsoft Graph SDK list subscribedskus not returning expected response

I'm trying to get a list of ConsumedUnits from the Microsoft Graph API using C# following this article:

https://learn.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!

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:

Collections

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM