In this basic article i will show you how to fetch the data back from Power Automate after passing it on to it.
I will use a simple example of calling an API from Power Apps through Power Automate and returning the data.
So for the start lets simple create a Canvas App with On Input Text Field and a submit button.
Now lets try to send this name to an API.
So click on the Submit button and then go to the Action Tab and Click Power automate and create a new Flow.
This will open a new window for Flow. For this demo purpose, i will use on of the standard templates for flow which is PowerApps Button
After the flow Canvas Window is opened, I will go to add a next action as an HTTP Request and will add the HTTP action.
In the method depending on your API you can actually use Get, Post, Put, Patch and Delete. For my API i will use the GET.
Now what we need is to get the URI from Power Apps and also the Queries. So i will click on URI field and will select the option of “Ask in PowerApps”
And then we will add another action to return the data back to Power Apps and will save my Flow
Now back in PowerApps Studio, I will go the same button and try to attach my flow to it. But before attaching i would want to save the output in a variable.
As soon as i added the flow it would asked me to provide a input parameter as in our flow we asked for the URI for API. So i enter my URL and Complete my function as below
Now i am saving the response of my flow in a variable called result. The result is an object type and will be used to reference the variable from my flow.
On the similar OnSelect i add the following code to get the response in a Notificaiton.
If(!IsBlank(result.response),Notify(result.response, NotificationType.Success), Notify(“There was an error”, NotificationType.Error))
Now let me show you the simple code of my API. I am simply outputting the name i get as a GET variable with a hello.
With that all set. Now is the time to use the app.
So in this simple article you learnt how to get a response back from your Power Automate into your Power Apps. Since the API returns a simple string it was easy.
Most of the API would return JSON format of the data and you would require to parse the JSON in Power Automate and return the variables only. We will discuss this in our future post.
tip: If you have already added the flow to the button and you go back to the flow to customize more outputs you might need to remove the flow from power apps and add again so all the outputs and inputs are recognized.