Performs a REST HTTP GET call supplying any request headers and/or parameters. Returns a RestResponse representing the response.
A GET is a read only call.
HTTP response headers - returns list of response headers as key-->value pairs. e.g "WWW-Authenticate", "Gateway"
Response body - returns the response body if the response is successful. If there is no response, this value will be null.
Example:
var gatewayId = "myGateway";
//set any headers
var headers = {"Content-Type":"application/json", "Accept":"application/json"};
//set params
var params = {"userId":fields.filter.value};
var opts = new RestOptions();
//setting the wait time to establish a connection to the target server to 5 seconds
opts.setConnectionTimeout(5);
//set the time to wait for no inactivity from the rest call to 10 seconds
opts.setSocketTimeout(10);
//set UTF-8 character set when decoding the response
opts.setResponseCharset("UTF-8");
var response = services.rest.get(gatewayId, "/users", headers, params, opts);
if(response.isSuccess())
{
var results = JSON.parse(response.getBody());
if(results)
{
//populate results using the JSON object
populateResults(results);
}
}
RestResponse contains the following data:
Example:
Further documentation.