1

I have the following code to get places from Microsoft Graph:

    var queryOptions = new List<QueryOption>() { new QueryOption("$count", "true") };         
    var roomUrl = graphClient.Places.AppendSegmentToRequestUrl("microsoft.graph.room");
    var response = await new GraphServicePlacesCollectionRequest(roomUrl, graphClient, queryOptions).Top(100).GetAsync();                    
    var nextPageUrl = response.AdditionalData.TryGetValue("@odata.nextLink", out object nextLink) ? nextLink.ToString() : string.Empty;

On running this, I see @odata.nextLink value is missing from the response (there should be a next page link). What am I missing?

user989988
  • 3,006
  • 7
  • 44
  • 91

1 Answers1

0
  • Some queries results in large list which can be limited in size for each page by using query $top to some number.In that case if results are more than that number @odata.nextLink value will be appeared in response .
  • But if the results are "less or equal" to the queried limit and there contains no more results or page than that, then @odata.nextLink property is not present that contains a URL to the next page of results in the response indicating, there are no more results than we got currently.

I have only one count in result when queried for getting places and so could not get nextlink property.

For example. Here I tried to get top 100 users.

GraphServiceClient graphClient = new GraphServiceClient( authProvider );
var queryOptions = new List<QueryOption>()
{
  new QueryOption("$count", "true")
};

var users = await graphClient.Users
  .Request( queryOptions )
  .Top(100)
  .GetAsync();

The response is exhausted and so no next page link as page has complete result .

enter image description here

In the below query I requested for top 5 results in one page, so it responded with @odata.nextLink property as the actual results have more than the 5 count and requires further pages to display next results.

var users = await graphClient.Users
  .Request( queryOptions )
  .Top(5)
  .GetAsync();

enter image description here

Reference : Paging Microsoft Graph data in your app - Microsoft Graph | Microsoft Learn

kavyaS
  • 8,026
  • 1
  • 7
  • 19
  • I have added 1000 rooms in my demo tenant. The url I use to get places should give next page link. – user989988 Oct 03 '22 at 14:03
  • Same here, I have more than 100 rooms and have used $top=100 in the Uri, but the @odata.nextlink isn't provided by Microsoft. This must be a bug. – geoced Jun 23 '23 at 14:33