How to – use HTTP Action to call DataVerse / Dynamics 365 Web API in Power Automate


Let us take a simple example, to see the steps involved.

Here we will be manually triggering a flow, getting the token, and calling the WhoAmI request in Microsoft Dataverse / Dynamics 365.

This is how our final Flow looks like.

Inside the first HTTP action, we are calling OAuth 2.0 token endpoint v1. We have MyCrmApp registered in Azure AD and have generated the client secret for it.

Also we have created an Application User using the above application details and have given the appropriate security role.

Below is how our HTTP request looks like.

 

Method

POST

URI

https://login.microsoftonline.com/489f9a0f-1326-42ae-a00c-0dd3cd16e6e9/oauth2/token

Headers

 

Content-Type

application/x-www-form-urlencoded

Body

grant_type=client_credentials&

client_id=ad7a1cc4-123f-4270-9c11-29eb1686e203&

client_secret=m7.xyzsdfsdfe.jZ0odh-C-85qg70QPfnsI&

resource=https://[orgname].crm.dynamics.com/

Next, we have added the Compose action to get the token from the output of the HTTP request.

 

Inputs (Expression) = outputs(‘HTTP’).body.access_token

Next, we have added the HTTP action again to calls the WhoAmI request using the above token.

Method

GET

URI

https://trialcrm.api.crm.dynamics.com/api/data/v9.2/WhoAmI

Headers

 

Content-Type

application/json

Authorization

Bearer [Output of the previous step]

On triggering our Flow succeeds as shown below.

The output of the first HTTP request.

Compose step has the access token

And the final step has the result of the HTTP Get request to WhoAmI

The helpful post –

https://carinaclaesson.com/2019/11/24/using-power-automate-to-trigger-on-create-or-update-in-the-cds-and-make-http-requests-with-oauth-2-0-authentication/

https://sharepointmadeeasy.blogspot.com/2018/02/microsoft-flow-http-rest-api-invalid.html

Hope it helps..

Check other posts on Power Automate

Advertisements

Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

3 thoughts on “How to – use HTTP Action to call DataVerse / Dynamics 365 Web API in Power Automate”

  1. Hi Nishant,

    If the requirement is just to call D365 action or CRUD operation Azure AD connector is already available to be used in flows which will take care of access token management.

    Thanks

    Like

Please share your thoughts

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

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