How does the pagination work on the /rest/resource version work?

Ali Chouikhi (Annalect) 0 Reputation points
2023-03-24T08:42:34.3933333+00:00

following the pagination doc does not help, it always returns a next page even tho the end is reached and always returns amount of elements corresponding to count set.

A have a case where i know that there are 1102 elements, i get that if i leave out the count and start.

If the count is set to more than elements then it returns correct elements with no paging links. if the count is set to below the total elements it return a next page links, which if used returns the exact same thing as the previous.

Can you look into it.

Microsoft Security | Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Anonymous
    2023-03-24T16:18:38.86+00:00

    Hello Ali Chouikhi (Annalect),

    Thanks for reaching out!

    I suggest you look closely at the Graph API pagination guide - Paging Microsoft Graph data in your app and Microsoft Graph throttling guidance

    Graph API endpoints return an @odata.nextLink property when pagination is triggered.

    Some queries against Microsoft Graph return multiple pages of data either due to server-side paging or due to the use of the $top query parameter to specifically limit the page size in a request. When more than one query request is required to retrieve all the results, Microsoft Graph returns an @odata.nextLink property in the response that contains a URL to the next page of results.

    For example, the following URL requests all the users in an organization with a page size of 5, specified with the $top query parameter:

    https://graph.microsoft.com/v1.0/users?$top=5
    

    If the result contains more results, Microsoft Graph will return an @odata.nextLink property similar to the following along with the first page of results:

    "@odata.nextLink": "https://graph.microsoft.com/v1.0/users?$top=5&$skiptoken=X%274453707 ... 6633B900000000000000000000%27"
    

    You can retrieve the next page of results by sending the URL value of the @odata.nextLink property to Microsoft Graph.

    https://graph.microsoft.com/v1.0/users?$top=5&$skiptoken=X%274453707 ... 6633B900000000000000000000%27
    

    Microsoft Graph will continue to return a reference to the next page of results in the @odata.nextLink property with each response until all pages of the results have been read. To read all results, you must continue to call Microsoft Graph with the @odata.nextLink property returned in each response until the @odata.nextLink property is no longer returned.

    Hope this helps.

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have further questions about this answer, please click "Comment".

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.