Now, there are several questions about how can we make HTTP requests from a Canvas Power App. Well, as of today, only HTTP with Azure AD exists in native Canvas Power App Connectors, so in order to call HTTP requests only to external resources, you’ll need to go via a Flow and get response back.
Call a Flow from within a Canvas Power App and capture the response back in the Canvas Power App.
In my example to keep things easy, I’m using a sample HTTP request provided by https://openweathermap.org/ (OpenWeatherMap) [I know there are native Weather connectors, but I’m just using as an example]
Here’s how Flow looks –
- Let’s say I create an Automated Flow which is triggered from a Power App. Just select that, there’s nothing to add to it.
- Next Step, I’ll make an HTTP request to a Service (In my example, I want to retrieve Humidity. You would of course have your use case)
I’ve used the same example in one of my posts where I talked about making HTTP requests using Flow. Check this post – Make HTTP request from Flow in Power Automate
- To breakdown my received HTTP response into distinct pieces of info, I’ll parse it.
- Final step would be to send back the parsed info to the Power App itself so that I can use the info internally in the Canvas Power App from which this Flow was called.
- Now, I’m choosing to send back the Humidity value. So, I’ll choose a type of Output to be sent my response into
- And since I already parsed the response in the step above, it’s easy to select what piece of info I want to send back to my Canvas Power App.
I’ve created a variable called as humidityValue and in that I’m passing humidity from the parsed JSON step.
- That’s it. My Flow overall looks like this
Canvas Power App
In my Canvas Power App, I only have a button which will populate the data into a label –
- Let’s say, I have a button called as Get Humidity. And below it, is a Label having “Humidity is” already written
- Now, the next step is to add the Flow in the Canvas Power App. Navigate to Action in the menu bar in Canvas Power App Studio and look for Power Automate
- On clicking it, you’ll be able to select the Flow you want to add in the Canvas Power App
- Once you select that, it’ll appear on the OnSelect formula bar of the button. Ideally, this should be added to whatever event you want the Flow to Run from (In my case, click of Get Humidity button)
It’ll populate with a default formula like below. But we need some modification for it to be populated to the Label.
- Now, you can write the below formula to add the value retrieved from the variable which you created dynamically called as ‘humidity‘ and upon adding dot to the Run(), you’ll be able to select the variable you passed to the Canvas App from Flow.
- So, the completed Formula looks like this.
Here, I’m using Set() function to set a dynamically declared variable in called as humidity and populate it with the value of humidityValue which we’ll get when we run Flow and the Flow will make an HTTP call to get that value.
In case you also need to understand how variables work, you can refer this post of mine – Variables in Canvas Power Apps | Global and Context
- Now, we need to set it to the Label. So, we’ll write a formula on the Label’s Text event. So that, the Label is displaying Humidity is <valueOfHumidity> variable
- And you’re set. Hope this explanation was easy. Now, let’s Run the App and click Get Humidity button
When I click a button, I’ll get the value into the Label field which I created.
When I click the button, it’ll be greyed out for a moment while the Canvas Power App calls the Flow and the Flow runs the HTTP request and sends back response to Canvas Power App.
Finally, once the variable is set, the Label control will display the value as below which came via HTTP using Flow
You can also see the results going in the Flow Run as well
Hope this was useful. Here are some more Canvas Power App & Power Automate posts you might want to look at –
- Send a Power App Push Notification using Flow to open a record in Canvas App | Power Automate
- Accept HTTP Requests in a Flow and send Response back | Power Automate
- Launch URL on a Data Table Text column selection in a Canvas PowerApp | SharePoint Lists
- Terminate a Flow with Failed/Cancelled status | Power Automate
- Aggregate functions in a Canvas Power App | Using on SharePoint Lists
- Logged In User details in a Canvas Power App
- Get N:N records in a Canvas Power App using Common Data Service connector | Power Platform
- Implement character length validation in a Canvas Power App | Power Platform
- Call a Dynamics 365 Action from Flow [Bound and Unbound Actions] | Power Automate
- Pause a Flow using Delay and Delay Until | Power Automate
- BPF Flow Step as a Trigger in CDS (Current Environment) connector | Power Automate
- Generate Dynamics 365 record link in a Flow using CDS connector | Power Automate
- Dependent OptionSets in a Canvas Power App for 1:N related CDS entities | Power Platform
- Implementing Exit app, Logout and Confirm Exit features in a Canvas Power App
- Using Parse JSON to read individual List Records in Flow|Power Automate