A C# console application sample using the Power Automate Web API to programmatically read/write Power Automate flows.
- Download or clone the repo so that you have a local copy.
- Open the sample solution in Visual Studio
- Review this article for guidance on interacting with API flows
- Replace the variable on line #17 with your Dataverse environment URL
- Uncomment the
RetrieveFlow
method call on line #40 - Update the variable on line #113 with flow ID (GUID)
- Run the project!
- Uncomment the
CreateFlow
method call on line #41 - Update the variable on line #61 with relevant clientData content
- Run the project!
- Uncomment the
- You will be prompted to enter a valid username and password.
- The account you provide must have access to the Dynamics CRM API's. (I have only tested this solution using a tenant global admin account.)
- If you have not run any CDS for Apps samples before, you will be asked to give consent.
- The auth functionality is borrowed from Jim Daly's sample. It's a great way to get started quickly, but should not be used to access sensitive/production data.
- The GET request for a single flow seems to fail intermittently. I have reported the behavior here.
- The
CreateFlow
method makes two different API calls. The first (POST) actually creates the flow and the second (PATCH) updates thestatecode
property to 1. This seems to be necessary and the flow will not function in the UI without such an update. - I have only been able to programmatically create/access flows within the Default Solution for a relevant Dataverse environment. Microsoft does not mention this limitation in the web API documentation and I am uncertain of the scalability/performance implications.
- When the sample is finished, press any key to exit.
- The
CreateFlow
method creates a Power Automate flow in the Solutions tab and then updates itsstatecode
property to 1. - The
RetrieveFlow
method retrieves the flow object matching the ID/GUID provided.