user989988
user989988

Reputation: 3736

Get incremental changes for a group using delta query in Microsoft Graph

I ran the following queries in MS Graph Explorer:

Query1:

https://graph.microsoft.com/v1.0/groups/[group-id]/transitiveMembers

Response includes 2 users:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#directoryObjects",
    "value": [
        {
            "@odata.type": "#microsoft.graph.user",
            "id": "id1"
            
        },
        {
            "@odata.type": "#microsoft.graph.user",
            "id": "id2"            
        }
    ]
}

Query2:

https://graph.microsoft.com/v1.0/groups/delta?$filter=id eq '[group-id]'

Response includes 3 users:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#groups",
    "@odata.nextLink": "https://graph.microsoft.com/v1.0/groups/delta?$skiptoken=abcd",
    "value": [
        {            
            "id": "[group-id]",
            "members@delta": [
                {
                    "@odata.type": "#microsoft.graph.user",
                    "id": "id1"
                },
                {
                    "@odata.type": "#microsoft.graph.user",
                    "id": "id2",
                    "@removed": {
                        "reason": "deleted"
                    }
                },
                {
                    "@odata.type": "#microsoft.graph.user",
                    "id": "id3"
                }
            ]
        }
    ]
}

Can someone please help me understand what is the difference between these two? I see that 2nd query has 3 users - 2 users + 1 removed user. Is that the only difference?

Also, I see that the response of 2nd query has @odata.nextLink and if run @odata.nextLink query:

https://graph.microsoft.com/v1.0/groups/delta?$skiptoken=abcd

I see @odata.deltaLink in the response.

{{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#groups",
    "@odata.deltaLink": "https://graph.microsoft.com/v1.0/groups/delta?$deltatoken=xyz",
    "value": [
        {            
            "id": "[group-id]",
            "members@delta": [
                {
                    "@odata.type": "#microsoft.graph.user",
                    "id": "id1"
                }
            ]
        }
    ]
}

Can I run @odata.deltaLink query:

"https://graph.microsoft.com/v1.0/groups/delta?$deltatoken=xyz"

to see upcoming changes to this group?

Upvotes: 0

Views: 1340

Answers (1)

Rukmini
Rukmini

Reputation: 15519

I tested in my environment and got the same results like below:

When I executed the transitive members query like below, it gives the existing nested members of the group.

enter image description here

I agree with Tiny Wang as mentioned in this MsDoc,

A group can have users, devices, organizational contacts, and other groups as members. This operation is transitive and returns a flat list of all nested members

When I executed delta query like below, it gives all the members including the removed group members.

enter image description here

  • If you get @odata.nextLink URL in the response, that means there may be additional pages of data to be returned in the process.
  • If you get @odata.deltaLink URL in the response, that means the existing state of the resource has no more data left to return. For future requests, you can use @odata.deltaLink URL to know about new changes of the resource .

The application continues making requests using the @odata.nextLink URL to retrieve all pages of data until a @odata.deltaLink URL is returned in the response.

Reference:

Use delta query to track changes in Microsoft Graph data - Microsoft Graph | Microsoft Docs

Upvotes: 1

Related Questions