Reputation: 21
Using the Power Automate Web API I can manage the cloud flows in solutions, however I also want to be able to execute flows. Is this possible through this Web API, or the Microsoft Dataverse Web API?
I can execute the flow if I use the url provided by the flow itself in an http request trigger, but I have no way to get or reverse engineer this url from the Power Automate API.
I have tried using the following:
but to no avail. Take into account I use a client id and client secret to get an access token.
Upvotes: 1
Views: 1086
Reputation: 21
This is a quick overview of my solution.
I first create an application in Azure with web authentication so I can use the redirection to get the login information and token.
Then I connect with oauth2 This requires a callback to get the token. The connection url looks like this:
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?scope={0}&response_type=code&client_id={1}&redirect_uri={2}&response_mode=query&state={3}
To get the flows of the team I call this using the token I get from the login process:
https://api.flow.microsoft.com/providers/Microsoft.ProcessSimple/environments/Default-[EnvironmentId]/flows?api-version=2016-11-01&$filter=search(%27team%27)&$top=50&$expand=properties.connectionreferences
After that I parse the response, get the ids of the flows and for each I call:
https://api.flow.microsoft.com/providers/Microsoft.ProcessSimple/scopes/admin/environments/Default-[EnvironmentId]/flows/[FlowId]/runs?api-version=2016-11-01&$expand=properties/trigger
This will return among other things the triggerUrl and the name of the flow.
Hope this helps.
Upvotes: 0