Azure logic app http request and response to Power Apps
Guide to call Logic app from Power Apps using http request!
What is Logic apps
Azure Logic Apps is a cloud-based service that helps you automate and orchestrate tasks, business processes, and workflows. It allows you to create workflows that integrate apps, data, services, and systems without needing to write much code. You can use it to connect different services, such as Office 365, Dynamics CRM, Salesforce, and many others, to automate tasks like data synchronization, file processing, and notifications.
What is Power Apps?
Power Apps is a suite of apps, services, connectors, and a data platform that provides a rapid application development environment to build custom apps for your business needs. With Power Apps, you can create custom business applications that connect to your data stored either in the underlying data platform (Microsoft Dataverse) or in various online and on-premises data sources like SharePoint, Microsoft 365, Dynamics 365, SQL Server, and more.
- Build apps quickly with a point-and-click approach to app design.
- Connect to various data sources using pre-built connectors.
- Deploy apps across multiple platforms including web, mobile, and tablets.
Prerequisite
- Logic App
- Power App
Creating the logic app
First, we create a simple logic app that has an HTTP request as a trigger. Compose a message that we are going to deliver, and a response back to the app. In my experience, this also works with more complicated flows, but where I was having issues is handling multiple branches to speed up the process.
Create an HTTP request trigger with methods like GET method, DELETE, PATCH, PUT or POST for more advanced flows.
Add a compose action, with the input Hello
Add an parallel branch, select compose action and set
the input to World!
Add a Response action. Go to Settings, look under Run after, and click on Select actions. Select Compose Message Part 2. Note: You can customize the options further by selecting 'Is successful', 'Has timed out', 'Is skipped', or 'Has failed' for each Run After action.
Navigate back to Parameters in the Response action.
Set the Status Code to 200 and set the body to both
composed messages. { "message":"@{outputs('Compose_message_part_1')}
@{outputs('Compose_message_part_2')}" }
Click Save. The HTTP request URL will now be generated.
Navigate back to the Overview page of your logic app
and click on Export -> Export to Power Apps.
Provide a Name and select your Environment in
Power Platform where your app is going to be located.
A
Custom Connector will be created in Power Platform
environment.
Creating the Power App
Create an app with a blank screen.
Add a button and a label to the screen.
Linking Power App and Logic app
Navigate to data and click on add data. Search for the Name you provided in the previous step. Click on it and click connect.
Click on the button and input the source name. Then add
.WhenaHTTPrequestisrecieved
or, if you have changed
your trigger action name, it will be named accordingly.
To
make it easier to work with, I have chosen to use:
Set(varMessage,'logic-ComposeMessage-dev-westeu-001'.WhenaHTTPrequestisrecievedinvoke().message)
Set the properties of your label to varMessage
.
Either Alt+Click on the button or click play and then
click the button.
Great! Your response should now display correctly.