Paging in MS Graph API

Yes. In Microsoft Graph you can assume that you'll always get the fully qualified URL for the @odata.nextLink. You can simply use the next link to get the next page of results, and clients should treat the nextLink as opaque (which is described in both OData v4 and in the Microsoft REST API guidelines here: https://github.com/Microsoft/api-guidelines/blob/master/Guidelines.md#98-pagination.
This is different from AAD Graph API (which is not OData v4), which doesn't return the fully qualified next link, and means you need to do some more complicated manipulations to get the next page of results.

Hence Microsoft Graph should make this simpler for you.

Hope this helps,


The above code did not work for me without adding a call to 'CurrentPage' on the last line.
Sample taken from here.

        var driveItems = new List<DriveItem>();
        var driveItemsPage = await graphClient.Me.Drive.Root.Children.Request().GetAsync();
        driveItems.AddRange(driveItemsPage.CurrentPage);
        while (driveItemsPage.NextPageRequest != null)
        {
            driveItemsPage = await driveItemsPage.NextPageRequest.GetAsync();
            driveItems.AddRange(driveItemsPage.CurrentPage);
        }

if you would like to have all users in single list, you can achieve that using the code that follows:

public static async Task<IEnumerable<User>> GetUsersAsync()
    {
        var graphClient = GetAuthenticatedClient();
        List<User> allUsers = new List<User>();
        var users = await graphClient.Users.Request().Top(998)
           .Select("displayName,mail,givenName,surname,id")
           .GetAsync();

        while (users.Count > 0)
        {
            allUsers.AddRange(users);
            if (users.NextPageRequest != null)
            {
                users = await users.NextPageRequest
                    .GetAsync();
            }
            else
            {
                break;
            }
        }
        return allUsers;
    }

I am using graph client library