Calling a REST service

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

Calling a REST service

#1

Postby Segi » Thu Jun 15, 2017 8:45 pm

Can anyone provide a working example of calling a REST service. I created a Rest Service and want to test it out but I am stuck. I don't understand how to get the body of the request. I think I am missing a mapping in the REST Web Service Resource
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#2

Postby Jon » Fri Jun 16, 2017 7:24 am

I don't use Rest Web Service Resources, I use the RestServices API (i.e. services.rest) instead - it's less work and doesn't need any mappings. Here's an example of a get call:

Code: Select all

var headers = {};
headers.fromDate = fields.filterDateFrom.value; 
headers.toDate = fields.filterDateTo.value; 
var restUrl = "xxxxxxxx/getEvents";
var response = services.rest.get(restUrl, headers, null);
if (response.success)
{
    var events = JSON.parse(response.body);
    for each (var event in events)
    {
      ..
    }
}
RestServices has a variety of get, post, put delete methods etc that accept various combinations of parameters, headers, body etc. See the documentation (services.rest. then Ctrl + Space) for more info.
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

#3

Postby Segi » Fri Jun 16, 2017 3:51 pm

Will do that thanks
0 x


Who is online

Users browsing this forum: No registered users and 124 guests