[Update May 2017 - There are new features making the consumption of REST service easier - check out this blog entry about BOPs]
One of the frequent requests we get when we demo ABCS is - can I invoke some external functionality that is exposed as a REST service and pass parameters to it.
Well, with a minimal amount of JavaScript coding you can do it in the current version.
I recorded the demo below that shows you how to do that.
I'm leveraging a public REST API that github exposes to get a list of repositories for a user. The service is available at https://api.github.com/users/oracle/repos
I then design an ABCS page that has a parameter field, a button that invokes the REST/JSON call, and a placeholder for results. It looks like this:
In addition the video also shows some other techniques that are useful, including:
It seems that right now you are restricted to accessing REST services that are secured over HTTPS protocol (which is a good thing).
Note that you of course don't have to stage the app to see it run, you can just go into live mode, or run it to see it working. I just wanted to make sure I have a demo out there that shows how staging works.
The JavaScript snippet I'm using in the video is:
$.getJSON("https://api.github.com/users/"+ +"/repos", function(result){
$.each(result, function(i, field){
$('[name="myOutput"]').append(field.name + " ");
});
});
resolve();
If you'll actually add a
$('[name="results"]').empty();
as the first link, it will clear the field for you each time you re-press the button.