MSAutomate

Graph in Power Automate – HTTP Connector

There are multiple ways to use Microsoft Graph within Power Automate. In this post, I’ll go over using the HTTP connector.

What is the HTTP connector?

The HTTP connector is a premium connector that allows you to invoke REST API. Not only can you use it to connect to Microsoft Graph, but you can also connect to pretty much anything that has a REST API.

HTTP Connector

Microsoft has a short learning module about HTTP connectors here: Overview of HTTP connectors in Power Automate – Learn | Microsoft Docs

Configuration of HTTP Connector for Microsoft Graph

In a previous post, I went over how to create an app registration for Microsoft Graph. For this demonstration, I’ll get a user’s profile information.

We will need some information from the app registration for this to work.

  1. In your Power Automate flow, add an HTTP action (This is a premium connector).
  2. For the method, select GET.
  3. For the URI, I’ll be using https://graph.microsoft.com/beta/users/<UPN OR ID>
    • Example URI: https://graph.microsoft.com/beta/users/jordan@bardwelldev.onmicrosoft.com
  4. Next, we will configure the authentication. If you don’t see the authentication drop-down, select Expand advanced options
  5. Select Active Directory OAuth as the Authentication. We will need to fill out the following:
    1. Tenant: Your Tenant ID
    2. Audience: https://graph.microsoft.com
    3. Client ID: Application (client) ID from the app registration
    4. Credential type: Secret
    5. Secret: Secret Value from the app registration
Authentication Configuration
  1. Next, I’m going to add the $select parameter under the Queries key/value area. I only want to return a few fields:
    • id
    • givenName
    • surname
    • usageLocation
    • userPrincipalName
  2. Key to add: $select
  3. Value to add: id,givenName,surname,usageLocation,userPrincipalName
$select parameter added

Next, save and test your flow. If successful, you should get a 200 in your status code and get some data back.

Copy and save the body output, we will need it later to generate a JSON Schema.

Successful GET of a user

So, how can we make the response body useful in Power Automate? We can parse it using the Parse JSON action.

Parsing Response from HTTP Connector

Now that we have our connector for Get User working, let’s parse the response body so we can use the data throughout the flow.

  1. Add a Parse JSON action below your HTTP action.
    • The Parse JSON action has 2 input fields: content and schema.
Parse JSON Action
  1. In the content field, put in the Body of the HTTP connector from above.
  2. Next, select Generate from sample. This will allow us to generate a schema from our body output.
  3. A window will pop up called Insert a sample JSON payload. This is where you can paste in the response body you copied earlier. But before we do that, let’s review the JSON response.

Example JSON Response:

{
  "@odata.context": "https://graph.microsoft.com/beta/$metadata#users/$entity",
  "id": "ad57b725-4713-48ce-9f3c-793c21108ce1",
  "displayName": "Jordan Bardwell",
  "givenName": "Jordan",
  "surname": "Bardwell",
  "usageLocation": "US",
  "userPrincipalName": "jordan@bardwelldev.onmicrosoft.com"
}
  1. Paste the response into the window, then select Done. You should now have a schema that looks like this:
{
    "type": "object",
    "properties": {
        "@@odata.context": {
            "type": "string"
        },
        "id": {
            "type": "string"
        },
        "givenName": {
            "type": "string"
        },
        "surname": {
            "type": "string"
        },
        "usageLocation": {
            "type": "string"
        },
        "userPrincipalName": {
            "type": "string"
        }
    }
}

Save your flow.

Now you can see the fields from our Parse JSON action in the dynamic content window and use the data throughout your flow.

Jordan Bardwell

Add comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Follow us

Don't be shy, get in touch. We love meeting interesting people and making new friends.

Most popular

Most discussed