Employee Photos change in Graph?

Carey, Chad 5 Reputation points
2024-02-22T19:44:04.26+00:00

We have had a process running for a very long time that would look at an employee's photo in Graph and compare it to an image we have on a file system to see if there was a photo change. We did this by looking for hash changes. On 2/17/2024 something changed and this no longer works because the hashes, even t hough the photos are the same, can change from one call to the next, sometimes they are still considered the same but 9 times out of 10, they are not. We started looking at Base64 strings as well and noticed that the Graph photo can be wildly different now from call to call for the same photo. So....What changed and how do we go about getting an authoritative photo now from Graph that we can compare to our saved photos?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
10,620 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Deepanshu Sharma 415 Reputation points Microsoft Vendor
    2024-03-03T16:09:07.5066667+00:00

    Hello Carey, Chad,

    The @odata.mediaEtag is a property used in the Microsoft Graph API to handle caching and track changes for user photos. Let me explain further:

    When you retrieve a user’s photo using the Graph API, you receive an ETag response header. This ETag represents a unique identifier for the photo data.

    1. Instead of fetching the entire binary image photo data each time, you can request the metadata of the photo. Specifically, you can use the following API call:
       GET /users/{user-id}/photo
       
    
    1. The ETag allows you to check if the photo has changed since your last request. If the ETag remains the same, the photo content hasn’t been modified. If it changes, you know that the photo has been updated.

    In summary, the @odata.mediaEtag property helps efficiently manage photo data by allowing you to track changes without fetching the entire image every time.