Why am I receiving a lot of records per one group when querying Microsoft Graph API using delta?

Sameh Tawfik (MiddleEast) 0 Reputation points
2024-05-16T20:33:26.14+00:00

I'm using the following endpoint to query Microsoft Graph API, tracking changes by delta:

https://graph.microsoft.com/v1.0/groups/delta?$select=id,displayName,members

However, when I filter the groups locally to find a specific group, I find many records (more than 100) retrieved for each single group as duplicates, most of these records without members. Why is this behavior when querying Graph API by delta? And how can I fix it? Thank you in advance!

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,916 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
19,948 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Niki Melanidou 115 Reputation points
    2024-05-17T10:43:44.7533333+00:00

    Here are a few reasons why you might be seeing duplicates:

    Multiple Change Events: Changes to a single group can trigger multiple change events. For example, if a group's displayName is updated, it might trigger one change event, while adding or removing members might trigger additional change events.

    Pagination: If there are more than 100 changes since the last delta token, Microsoft Graph API paginates the results. This means that you might receive multiple pages of results for the same group, each containing the same group with different changes.

    To address this behavior and eliminate duplicates, you can consider the following approaches:

    Filtering on the Client Side: After receiving the delta query results, filter out duplicates on the client side. You can track the groups you've already processed and ensure that you only process each group once.

    Use of Delta Links: Microsoft Graph API provides delta links in the response, which can help you track the next page of changes. Make sure you're using these delta links to fetch subsequent pages of changes rather than making repeated queries with the same delta token.

    Refining Query Parameters: Refine your query parameters to only request the specific changes you're interested in. For example, if you're only interested in changes to group memberships, you can filter your delta query accordingly.

    Investigate Change Events: Investigate the change events returned by the delta query to understand why multiple events are being triggered for the same group. This can help you better understand the behavior and tailor your handling accordingly.

    0 comments No comments