How to apply a variable to an extension attribute of onPremisesExtensionAttributes in Microsoft Graph?

Grace Tran 0 Reputation points
2023-12-13T10:09:06.1333333+00:00

I want to apply a variable like the value of manager to an extension attribute of onPremisesExtensionAttributes in Microsoft Graph.

How can I do this? And please give me the command to execute in case it's able to do this.

WXWorkCapture_17024541168215

Microsoft Security Microsoft Graph
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Diah.Karim-MSFT 335 Reputation points Microsoft External Staff
    2023-12-20T01:17:47.9066667+00:00

    Hi Grace,

    To apply above value, you can use with couple of approach for i.e using from Graph Explorer https://developer.microsoft.com/en-us/graph/graph-explorer, from code using MS Graph SDK https://learn.microsoft.com/en-us/graph/sdks/sdks-overview or from Powershell https://learn.microsoft.com/en-us/powershell/microsoftgraph/?view=graph-powershell-1.0.

    But in your case, i think you can utilise Graph Explorer. It's a developer tool (with simple UI) that lets you conveniently make Microsoft Graph REST API requests and view corresponding responses. Use Graph Explorer to try APIs in a development tenant to explore capabilities and use it as a prototyping tool to fulfill your scenarios.

    Steps:

    1. Open https://developer.microsoft.com/en-us/graph/graph-explorer from your browser, and then Sign-in using your M365 account
    2. After signing, get your Id from this endpoint https://graph.microsoft.com/v1.0/me

    GetId

    1. Change the http method to "Patch" then put this value in the endpoint https://graph.microsoft.com/v1.0/users/yourId. Put below json data in the request body
    {
        "onPremisesExtensionAttributes": {
            "extensionAttribute1": "manager"
         }
    }
    

    And then, ensure to grant permission for User.ReadWrite.All from modify permission tab. Your may require your global administrator to approve the consent. Here is the patch screenshot

    Patch

    1. Once everything configured, then run query. To verify the changes takes effect, call this endpoint.

    https://graph.microsoft.com/v1.0/users/68a29129-aea9-4802-a70a-7e256dcd7dde?$select=id,displayName,onPremisesExtensionAttributes

    68a29129-aea9-4802-a70a-7e256dcd7dde - yourId

    Hope this helps.

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".


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.