question

CsabaEgyd-9776 avatar image
0 Votes"
CsabaEgyd-9776 asked CsabaEgyd-9776 answered

GRAPH Page Iterator returns same items multiple times

I have implemented a function using Graph SDK based on the public documentation found here:
https://docs.microsoft.com/en-us/graph/paging

While it is working, the callback is called correctly by each 2 items (Top(2)), the subsequent iterations (@odata.nextLink) contain overlapping person objects.

If I use a higher number in Top than the total number of people in the folder, e.g. Top(100), then all Persons are delivered correctly.
My first thought was that it may failed because because of a missing order by clause, but it still keeps failing after adding it.

Comment by user2250152 on SO:
Looks like a bug in Graph API. I've tried your query
(graph.microsoft.com/v1.0/users{user_id}/people?$top=2&$select=displayName,scoredEmailAddresses&$orderBy=displayName)
in Graph Explorer (developer.microsoft.com/en-us/graph/graph-explorer) and the query returns still the same two records for each page.

My original SO question: (https://stackoverflow.com/questions/71811808/graph-pageiterator-returns-same-items-multiple-times)


 public async Task<Dictionary<string, string>> LoadDisplayNames(string UserId)
 {
     User GRAPHUser = await GetUser(UserId);
     Dictionary<string, string> ret = new Dictionary<string, string>();
     try
     {
         var Persons = await _service.Users[GRAPHUser.Id].People.Request()
             .Top(2)
             .OrderBy("displayName")
             .Select(e => new
             {
                 e.ScoredEmailAddresses,
                 e.DisplayName
             })
             .GetAsync();
         var pageIterator = PageIterator<Person>.CreatePageIterator(
                     _service,
                     Persons,
                     (p) =>
                     {
                         var HighestScoreAddress = p.ScoredEmailAddresses.OrderBy(a => a.RelevanceScore).FirstOrDefault();
    
                         if (HighestScoreAddress != null && !ret.ContainsKey(HighestScoreAddress.Address))
                         {
                             var email = HighestScoreAddress.Address.Replace("SMTP:", "");
                             ret.Add(email, $"{p.DisplayName} ({email})");
                         }
                         return true;
                     }
                 );
         await pageIterator.IterateAsync();
     }
     catch (Exception ex)
     {
         Logger.Error(ex, ex.Message);
     }
    
     return ret;
 }



microsoft-graph-paging
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for reporting the issue, could you please confirm what i understand is correct or not?

whenever you run API - https://graph.microsoft.com/v1.0/me/people?$top=3&$select=displayName,scoredEmailAddresses&$orderBy=displayName

it returns 3-person object (screenshot 1), and the same person object is also returned in @odata.nextLink

Screenshot 1:
192783-image.png

Screenshot 1:
192754-image.png


1 Vote 1 ·
image.png (50.6 KiB)
image.png (43.7 KiB)
CsabaEgyd-9776 avatar image
0 Votes"
CsabaEgyd-9776 answered CsabaEgyd-9776 commented

Hi, thanks for the quick reaction.

Yes, exactly this is happening. I receive the same objects several times in the subsequent iterations.
Not always the same but one item is returned several times, and others also come up again and again eventually.

· 2
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Thanks for the confirmation, will take a deep into that and discuss with our developers.

1 Vote 1 ·
CsabaEgyd-9776 avatar image CsabaEgyd-9776 VickyKumarMindtreeConsultingPVTLTD-5545 ·

Great, thank you so much!

0 Votes 0 ·
CsabaEgyd-9776 avatar image
0 Votes"
CsabaEgyd-9776 answered

I'd like to kindly inquire about the status of this issue. Thx.

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.