I am playing around with Microsoft PowerApps and Microsoft Flow. I am trying to figure out how to make API calls from PowerApps and return the results(Status and Body) to a field such as a text box in my app.
I can make the HTTP requests through Flow and put them in a static file such as an excel spreadsheet...etc. I can also make the calls from a PowerApps control such as a button but all I know how to do with it is return it to something like an excel file, when really I want to return it to a Text Box or Text Area.
It is relatively straightforward to visualize API (JSON) responses using a PowerApps Gallery Control.
Do this:
ClearCollect(colResponse, myFlow.apiRequest())
Function to a Button Control in the PowerAppcolResponse
(View/Collections) to ensure it has contentItems
Property to colResponse
Text
Property to ThisItem.<someColumn>
Depending on the shape of your JSON response (flat or nested table), you may have to do some wrangling.
There are 3 areas to focus your wrangling:
On the ClearCollect
Function.
a. Add some dot notation to the end of this to "dig" into the API response before it hits the Gallery Control
b. Example: ClearCollect(colResponse, myFlow.apiRequest()).someColumn
On the Gallery Control Items
Property
a. Add some dot notation to the end of colResponse
to "dig" into the Collection
b. Example: colResponse.someColumn
On the TextBox Control within the Gallery
a. Add the First()
Function to the Text
Property
b. Example: `First(ThisItem.someColumn).someColumn2'
c. Note: There are some JSON schemas that require MULTIPLE First()
's to "dig" into the correct level. `First(First(ThisItem.someColumn).someColumn2).someColumn3' etc.
See this video for tips on visualizing API responses in PowerApps Galleries.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With