1

I have registered an application and provided the required permission in Azure and using that application to retrieve the modified users via delta Query.

Below is the code.

var pagedCollection = await graphClient.Users
                      .Request()
                      .Delta()
                      .Select("userPrincipalName,mobilePhone")
                      .GetAsync();

But the response does not contain the nextLink or deltaLink as mentioned in the documentation.

enter image description here

I can get the above links if I test the API in the graph explorer.

https://graph.microsoft.com/v1.0/users/delta

Response from Graph Explorer.

enter image description here

Am I missing anything here while calling the same API using C#?

Any help on this will be appreciated!

dhruvil29
  • 211
  • 1
  • 10

1 Answers1

-1

You can try below code:

                List<Microsoft.Graph.User> usersList = new List<Microsoft.Graph.User>();
                var users = await graphClient.Users.Delta().Request().Top(10).GetAsync();

                // Add the first page of results to the user list
                usersList.AddRange(users.CurrentPage);

                try
                {
                    while (users.AdditionalData.ContainsKey("@odata.nextLink") && users.AdditionalData["@odata.nextLink"].ToString() != null)
                    {
                        users.InitializeNextPageRequest(graphClient, users.AdditionalData["@odata.nextLink"].ToString());
                        users = await users.NextPageRequest.GetAsync();
                        usersList.AddRange(users.CurrentPage);
                    }
                }
                catch (Exception e)
                {

                }

Reference link: Microsoft Graph API Pagination is not working for getting all users from Azure AD

Dikesh Gandhi
  • 447
  • 13
  • 22
  • Could you please let me know how to get "members@delta" from users.AdditionalData? On running users.CurrentPage[0].AdditionalData["members@delta"], I get error The given key 'members@delta' was not present in the dictionary. I tried adding if condition (users.CurrentPage.Count > 0 && users.CurrentPage[0].AdditionalData != null && users.CurrentPage[0].AdditionalData.ContainsKey("members@delta")) but that didn't help. – user989988 Aug 17 '22 at 21:04