Users delta collection returns "empty" records

Viewed 293

We are trying to call this MS Graph endpoint:

https://graph.microsoft.com/v1.0/users/delta?$deltatoken=<DELTA_TOKEN>&$select=id,displayName,givenName,surname,employeeId,accountEnabled,assignedLicenses,assignedPlans,licenseAssignmentStates,usageLocation,userPrincipalName,userType,businessPhones,mail,mailNickname,mobilePhone,proxyAddresses,streetAddress,city,country,companyName,department,jobTitle,officeLocation,postalCode,state,isResourceAccount,createdDateTime,deletedDateTime,lastPasswordChangeDateTime,onPremisesLastSyncDateTime,onPremisesDistinguishedName,onPremisesDomainName,onPremisesImmutableId,onPremisesSamAccountName,onPremisesSecurityIdentifier,onPremisesSyncEnabled,onPremisesUserPrincipalName

This is what we get:

"value": [
    {
        "displayName": "Jozef Surname",
        "givenName": "Jozef",
        "surname": "Surname",
        "userPrincipalName": "jozef.surname@company.com",
        "mail": "jozef.surname@company.com",
        "id": "048...3d-eaf2-4199-8e88-9cd6...2091b"
    },
    {
        "displayName": null,
        "givenName": null,
        "surname": null,
        "userPrincipalName": null,
        "mail": null,
        "id": "ae...ecf-8ae8-4666-b158-93...c799c00"
    },
    {
        "displayName": null,
        "givenName": null,
        "surname": null,
        "userPrincipalName": null,
        "mail": null,
        "id": "33...d09-81a9-4304-833d-71...92f4b6a"
    },

The question is, why are we getting records with null fields? We would expect records like the first one in above example. When we query for some empty record (record with nulls) (https://graph.microsoft.com/v1.0/users/ae...ecf-8ae8-4666-b158-93...c799c00), we get this:

{
"@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity",
"businessPhones": [],
"displayName": "Zuzana Surname4",
"givenName": "Zuzana",
"jobTitle": null,
"mail": "zuzana.surname4@company.com",
"mobilePhone": null,
"officeLocation": null,
"preferredLanguage": null,
"surname": "Surname4",
"userPrincipalName": "zuzana.surname4@company.com",
"id": "ae...ecf-8ae8-4666-b158-93...c799c00"

}

It’s an existing user. We just don’t know why it’s returned with null fields when we call /users/delta with deltaToken?

We would expect a response like this one (no “empty” records):

"value": [
    {
        "displayName": "Jozef Surname",
        "givenName": "Jozef",
        "surname": "Surname",
        "userPrincipalName": "jozef.surname@company.com",
        "mail": "jozef.surname@company.com",
        "id": "04...33d-eaf2-4199-8e88-9c...b82091b"
    },        
    {
        "displayName": "Nick Surname2",
        "givenName": "Nick",
        "surname": "Surname2",
        "userPrincipalName": "nick.surname2@company.com",
        "mail": "nick.surname2@company.com",
        "id": "4f...faa-f1eb-462b-be31-e5...5860a25"
    },                
    {
        "displayName": "Jan Surname3",
        "givenName": "Jan",
        "surname": "Surname3",
        "userPrincipalName": "jan.surname3@company.com",
        "mail": "jan.surname3@company.com",
        "id": "25...f04-dbec-4580-b35b-3a...262b38c"
    },

Is this a bug in /users/delta with deltaToken or is it expected behavior?

Thanks for any help.

3 Answers

With the above behavior, it is not possible to differentiate between a property that has not changed and one that has changed to a null value.

By default, requests using a delta link or next link return the same properties as selected in the initial delta query in the following ways:

  1. If the property has changed, return the property in the JSON response.
  2. If the property has been set to an empty value, return the property value as null.

  3. If the property has not changed, return the value as null.

yes exactly it should work how the documentation says and it is working this way with other tenants. However we are getting the properties which have the value (like UPN) with null values in the reponse. According to the documentation it should come with the current value of the property or if value was never set the property shouldn't be part of the response at all. It's really weird behavior..

The other part of MS docs says:

By default, requests using a deltaLink or nextLink return the same properties as selected in the initial delta query in the following ways:

  • If the property has changed, the new value is included in the response. This includes properties being set to null value.
  • If the property has not changed, the old value is included in the response.
  • If the property has never been set before it will not be included in the response at all.

What is pretty inconsistent with the MS docs from the answer above.

The question is what will "$select" does if it is used for the property which was not supposed to be part of the response, based on the condition above.

Related