GatewayRestServices.get

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.

RestResponse contains the following data:

  • HTTP response code - returns a HTTP response code e.g 200 (OK)
  • 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);
      }
 }
 
Further documentation.

returns RestResponse

Parameters

java.lang.String  gatewayId,  java.lang.String  endpoint,  java.util.Map  headers,  java.util.Map  parameters,  RestOptions options,