microsoft-graph-api

Returning employeeId of a user through MS Graph API


I've been trying to return the employeeId of a user through the Microsoft Graph API but so far haven't had much luck.

I'm assuming this is probably because it doesn't exist in the metadata for the user in the Graph API so makes sense.

However, the property is populated in Azure AD. If I use the AZ command prompt to query the user I can see the property. Likewise, if I query the old Active Directory Graph API endpoint I can even see it there.

For example, querying https://graph.windows.net/{tennant}/users/{upn}?api-version=1.6 directly I receive the employeeId as part of the response (using the ActiveDirectoryClient however seems to ignore this property and doesn't store it anywhere).

Is there any reason for this? Wouldn't it make sense to have it returned as an additional property? I've also looked into extensions, but as it's not an extension isn't returned there.

Any help would be appreciated. I can get the information I need by querying the old endpoint directly, but this seems like a complete backwards step and involves multiple queries to get the information I need - including having to use multiple end points (one of which I assume will be deprecated and removed soon).


Solution

  • EmployeeId is currently a beta feature and is only available in the beta endpoint of the Graph API.

    So if you want to access the beta endpoint you just have to change the version to beta in your url. For example:

    https://graph.microsoft.com/beta/me/
    https://graph.microsoft.com/beta/users/{id|upn}/
    https://graph.windows.net/{tennant}/users/{id|upn}?api-version=beta
    

    For more information about the user-object in the beta endpoint see: https://developer.microsoft.com/en-us/graph/docs/api-reference/beta/resources/user