How to get users Birthday using graph api ?

Shahab Matapour 25 Reputation points
2023-01-16T10:19:11.5633333+00:00

Hi guys,

I tried to get users birthday using graph api call, in graph explorer I tried https://graph.microsoft.com/v1.0/users?$select=displayName,mail,id,jobTitle,birthday and https://graph.microsoft.com/v1.0/users?$select=displayName,mail,id,jobTitle,SPS-Birthday but it doesn't work. Through spo admin 'userprofile' section I added a refineable string and maped it to 'SPS-Birthday' then the status of crawled and Idled but also doesn't work.

Please guide me how to get users birthday property using graph call.

Thanks in advance.

Microsoft Security Microsoft Entra Microsoft Entra ID
Microsoft Security Microsoft Graph
0 comments No comments
{count} vote

Accepted answer
  1. Harpreet Singh Matharoo 8,396 Reputation points Microsoft Employee Moderator
    2023-01-16T10:46:46.1266667+00:00

    Hello @Shahab Matapour

    The birthday property is not a standard property of the User resource in the Microsoft Graph API. It's also not a custom property that can be added to the SharePoint User Profile Service and then retrieved via the Graph API.

    One option to achieve this is to store the birthday as a custom extension property on the Azure Active Directory (AAD) user object, and then retrieve it using the Graph API. Here are the steps to do this:

      1. Use the Azure AD PowerShell module to create a custom extension property on the AAD user object:
    Connect-AzureAD
    $extensionName = "birthday"
    $extension = New-AzureADUserExtension -Name $extensionName -DataType DateTime
    
    • Use the Graph API to set the custom extension property on a user:
    PATCH https://graph.microsoft.com/v1.0/users/{user-id}
    {
        "extensions": [
            {
                "@odata.type": "#microsoft.graph.openTypeExtension",
                "extensionName": "birthday",
                "birthday": {
                    "dateTime": "2000-01-01T00:00:00Z",
                    "timeZone": "UTC"
                }
            }
        ]
    }
    
    • Use the Graph API to retrieve the custom extension property on a user:
    GET https://graph.microsoft.com/v1.0/users/{user-id}?$select=displayName,mail,id,jobTitle,extensions
    

    Note that, you will need to have the appropriate permissions to create, update and read the custom extension property on the AAD user object. You may also need to wait for a full user profile sync to happen for the custom property to be indexed properly.

    Another option is to store the information in another service like Sharepoint or OneNote and then access it via the Graph API.

    I hope this helps.

    Please "Accept the answer" if the information helped you. This will help us and others in the community as well.

    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.