Sometimes the CDS (soon to be Microsoft Dataverse, join the confusion here: https://readyxrm.blog/2020/11/16/what-is-the-microsoft-dataverse/) endpoint doesn't offer the operation details you want to do in you Power Automate Flow. For example actions like calculate a rollup field or generate a pdf can be tricky to setup the right request body. This article show you how to use Power Automate D365 API call
For overcome this issue we want to share a simple child-flow that can be used for a custom MS Dataverse endpoint call.
Create a child flow to invoke HTTP request to D365
Our child record should be triggered manually (also includes invocation from another flow) and contain the necessary properties to dynamically create the HTTP request:
First we need to initialize the variables to authenticate with the D365 environment. In our example we use an application user. For that we need the Azure Active Directory ID (AAD ID), Client-ID and Client-Secret from an app registration. See this article.
After we know the variable values we can get a token from D365:
After that we parse the response to JSON:
Now we are able to execute the request using the access_token node of our parsed JSON response. The method, URI, Query and Request Body are taken from the manual trigger of the child-flow.
Finally we return the response and status code to the calling entity:
Calling a child flow for custom HTTP Request to D365
We can now use our child flow to create custom calls. In this example we generate a PDF using the Microsoft.Dynamics.CRM.documenttemplate action.
Thanks for reading and have fun creating custom HTTP calls to D365!
Add new comment