Rest API calls with PowerApps - api

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.

Today you cannot access the raw HTTP status/body from a PowerApp. The way to call "arbitrary" HTTP endpoints is to use Custom APIs that you can describe using Swagger. I wrote a quick blog on how to call Azure functions that shows how to craft a swagger to call the API: https://powerapps.microsoft.com/en-us/blog/using-azure-functions-in-powerapps/
Might be good if you could clarify the specific scenario you are trying to build to see if there are other ways, but one option that comes to mind is to build a custom API that receives the URL and on the server-side performs the HTTP request and returns the values in an object that then you can easily access in PowerApps.

It is relatively straightforward to visualize API (JSON) responses using a PowerApps Gallery Control.
Do this:
Ensure the Flow has the correct JSON response before proceeding
Add ClearCollect(colResponse, myFlow.apiRequest()) Function to a Button Control in the PowerApp
Execute the API call (click the button)
Inspect colResponse (View/Collections) to ensure it has content
Insert a blank Gallery Control
Set its Items Property to colResponse
Insert a TextBox Control into the Gallery
Set its 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.

Related

Qlik sense - Get selected id in custom exception

I am using qlik sense and i am writing a custom extension to display a chart. I want to know if there is way which all rows are selected in other extensions in my custom extension.
Scenario:
I am using two extensions in my sheet
Filter pane(inbuild) - which filters a list of ids
Chart extension (Custom written) - displays a chart
My scenario is, i use a REST Api call to get the data for my custom extension. When the filter is activated and some ids are filtered, i need to send these ids to back end to get the updated list for updating my custom chart.
Is there any way to do this ?? Please help i am stuck.
If I understand you correctly, you want to know the current selections of your filter pane object and then send these id's to your custom chart.
There are multiple ways to achieve this, here are a couple starting points:
Qlik Engine JSON API
Capability API -> Selection API
Capabilitiy API -> App API -> createList method
I would use the last option and combine it with these resources: Link 1 & Link 2

I need to display data form API in tabular form in wix

In my website i have to show data in tabular form which I am getting from API. I successfully integrated API and I am getting response from that API but the problem is I don't know how to show it in a tabular form in Wix.
I tried dynamically adding HTML code in script file but it is not working. Please let me know if there is a way I can do it.
You can put your data in a table element using the rows property.

POST a HTML Form programmatically?

I need to POST a HTML form to a 3rd party website (a Mass-SMS texting system).
In the past I've done this by forwarding to a page containing a form I've pre-populated and hidden (using display:none), then I've ran a javascript function at the end of the page to automatically submit this form.
However I'm hoping theres someway I can do all this programmatically (as I don't care about the response, and the user doesn't need to see the page the form is being posted to).
How can I do this? Cheers
You could use a WebClient.UploadValues method to send an HTTP POST request to a remote server from your code behind. Just fill up the name/value collection with the values coming from the hidden fields.
If you're willing to get into PHP, you can very easily use cURL for this.
Otherwise it's going to be quite difficult using just Javascript.
See here for a detailed tutorial.

Is there a way to find the browser window height and width in VB.Net without having using javascript?

I am needing to get the browser height and width of the browser window with vb. I can get these values by setting an ASP.Net hidden input control using javascript, after the page has loaded and a post back is done. I need to be able to get these values when the page initially loads so I can create an image based on those values.
I am still new at VB.Net, so any help would be great. Thanks!
Quick answer: No, you cannot.
BUT: You may have access to those values by looking at the request headers values.
Please note that the value may not always be there and that different browser may or may not sent those values with different keys.
The best way to have this value should be usign javascript or vbscript (ie CLIENT script). You may use ajax you create your image async way.
ASP.NET is a SERVER side programming language (like JSP or PHP) and has nothing to do with which browser access it...
Look at it this way, what is the screen size of Google Bot "browser" ? Or what if a access your site with telnet ?
So you should use client script to have acces to client properties.
Do not hesitate to comment if I am not clear or right.

how to read/parse dynamically generated web content?

I need to find a way to write a program (in any language) that will connect to a website and read dynamically generated data from the website.
Note that it's dynamically generated--it's not enough to get the source html, because the data I'm interested in is generated via javascript that references back-end code. So when i view the webpage source, I can't see the data. (For example, go to google, and do a search. Check the source code on the search results page. Very little of the data your browser is displaying is reflected in the source--most of it is dynamically generated. I need some way to access this data.)
Pick a language and environment that includes an HTML renderer (e.g. .NET and the WebBrowser control). Use the HTML renderer to get the URL and produce an HTML DOM in memory (making sure that scripting is enabled). Read the contents of the HTML DOM after the renderer has done its work.
Example (you'll need to do this inside a System.Windows.Form derived class):
WebBrowser browser = new WebBrowser();
browser.Navigate("http://www.google.com");
HtmlDocument document = browser.Document;
// extract what you want from the document
I used to have a Perl program to access Mapguide.com to get the drive direction from one location to another location. I parsed the returned page and save to database. If the source never change their format, it is OK. the problem is the source format often change, your parser also need change.
A simple thought: if we're talking about AJAX, you can rather look up the urls for the dynamic data. Then you can use the javascript on the page you're talking about to reformat this.
If you have Firefox/greasemonkey making a DOM dumper should be a simple matter.