Class RestServices

java.lang.Object
com.ebasetech.xi.services.RestServices
All Implemented Interfaces:
java.io.Serializable

public class RestServices
extends java.lang.Object
implements java.io.Serializable
RestServices provides static methods that provide methods to access REST services. Each HTTP method is available as a method call:
e.g HTTP GET has a corresponding method of get(String uri)
Since:
V5.1
See Also:
Serialized Form
  • Constructor Summary

    Constructors
    Constructor Description
    RestServices()  
  • Method Summary

    Modifier and Type Method Description
    static java.lang.String[] accessMethods​(java.lang.String uri)
    Returns an array of available HTTP methods to a resource after a HTTP OPTIONS call.
    static java.lang.String[] accessMethods​(java.lang.String uri, Authentication authentication)
    Returns an array of available HTTP methods to a resource after a HTTP OPTIONS call.
    static java.lang.String[] accessMethods​(java.lang.String uri, Authentication authentication, RestOptions options)
    Returns an array of available HTTP methods to a resource after a HTTP OPTIONS call.
    static RestResponse delete​(java.lang.String uri)
    Performs a REST HTTP DELETE call and returns the HTTP response code.
    static RestResponse delete​(java.lang.String uri, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters)
    Performs a REST HTTP DELETE call and returns the HTTP response code.
    static RestResponse delete​(java.lang.String uri, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters, Authentication authentication)
    Performs a REST HTTP DELETE call and returns the HTTP response code.
    static RestResponse delete​(java.lang.String uri, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters, Authentication authentication, RestOptions options)
    Performs a REST HTTP DELETE call and returns the HTTP response code.
    static RestResponse get​(java.lang.String uri)
    Performs a REST HTTP GET call and returns a RestResponse representing the response.
    static RestResponse get​(java.lang.String uri, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters)
    Performs a REST HTTP GET call supplying any request headers and/or parameters.
    static RestResponse get​(java.lang.String uri, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters, Authentication authentication)
    Performs a REST HTTP GET call supplying any request headers and/or parameters.
    static RestResponse get​(java.lang.String uri, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters, Authentication authentication, RestOptions options)
    Performs a REST HTTP GET call supplying any request headers and/or parameters.
    static java.lang.String getLocalUrlBase()
    Returns a base URL to invoke a RESTful service on this server using localhost i.e.
    static RestResponse head​(java.lang.String uri)
    Performs a REST HTTP HEAD call on a resource.
    static RestResponse head​(java.lang.String uri, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters)
    Performs a REST HTTP HEAD call on a resource.
    static RestResponse head​(java.lang.String uri, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters, Authentication authentication)
    Performs a REST HTTP HEAD call on a resource.
    static RestResponse head​(java.lang.String uri, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters, Authentication authentication, RestOptions options)
    Performs a REST HTTP HEAD call on a resource.
    static RestResponse options​(java.lang.String uri)
    Performs a REST HTTP OPTIONS call and returns the HTTP response code.
    static RestResponse options​(java.lang.String uri, Authentication authentication)
    Performs a REST HTTP OPTIONS call and returns the HTTP response code.
    static RestResponse options​(java.lang.String uri, Authentication authentication, RestOptions options)
    Performs a REST HTTP OPTIONS call and returns the HTTP response code.
    static RestResponse patch​(java.lang.String uri, java.lang.String body)
    Performs a REST HTTP PATCH call.
    static RestResponse patch​(java.lang.String uri, java.lang.String body, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters)
    Performs a REST HTTP PATCH call supplying any headers and/or parameters required.
    static RestResponse patch​(java.lang.String uri, java.lang.String body, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters, Authentication authentication)
    Performs a REST HTTP PATCH call supplying any headers and/or parameters required.
    static RestResponse patch​(java.lang.String uri, java.lang.String body, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters, Authentication authentication, RestOptions options)
    Performs a REST HTTP PATCH call supplying any headers and/or parameters required.
    static RestResponse post​(java.lang.String uri, java.lang.String body)
    Performs a REST HTTP POST call.
    static RestResponse post​(java.lang.String uri, java.lang.String body, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters)
    Performs a REST HTTP POST call supplying any headers and/or parameters required.
    static RestResponse post​(java.lang.String uri, java.lang.String body, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters, Authentication authentication)
    Performs a REST HTTP POST call supplying any headers and/or parameters required.
    static RestResponse post​(java.lang.String uri, java.lang.String body, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters, Authentication authentication, RestOptions options)
    Performs a REST HTTP POST call supplying any headers and/or parameters required.
    static RestResponse put​(java.lang.String uri, java.lang.String body)
    Performs a REST HTTP PUT call.
    static RestResponse put​(java.lang.String uri, java.lang.String body, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters)
    Performs a REST HTTP PUT call supplying any headers and/or parameters required.
    static RestResponse put​(java.lang.String uri, java.lang.String body, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters, Authentication authentication)
    Performs a REST HTTP PUT call supplying any headers and/or parameters required.
    static RestResponse put​(java.lang.String uri, java.lang.String body, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters, Authentication authentication, RestOptions options)
    Performs a REST HTTP PUT call supplying any headers and/or parameters required.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • RestServices

      public RestServices()
  • Method Details

    • get

      public static final RestResponse get​(java.lang.String uri)
      Performs a REST HTTP GET call and 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", "Bearer"
      • Response body - returns the response body if the response is successful. If there is no response, this value will be null.

      Example:

       var response = services.rest.get("http://example.com/rest/users");
       if(response.isSuccess())
       {
            var results = JSON.parse(response.getBody());
            if(results)
            {
                 //populate results using the JSON object
                 populateResults(results);
            }
       }
       
      Further documentation.
      Parameters:
      uri - the full URI of the request
      Since:
      V5.1
      See Also:
      RestResponse, get(String, Map, Map, Authentication)
    • get

      public static final RestResponse get​(java.lang.String uri, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters)
      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", "Bearer"
      • Response body - returns the response body if the response is successful. If there is no response, this value will be null.

      Example:

       var uri = "http://example.com/rest/users";
       //set any headers
       var headers = {"Content-Type":"application/json", "Accept":"application/json"};
       //set params
       var params = {"userId":fields.filter.value};
       var response = services.rest.get(uri, headers, params);
       if(response.isSuccess())
       {
            var results = JSON.parse(response.getBody());
            if(results)
            {
                 //populate results using the JSON object
                 populateResults(results);
            }
       }
       
      Further documentation.
      Parameters:
      uri - the full URI of the request
      headers - Map of HTTP request headers
      parameters - Map of HTTP request query parameters
      Since:
      V5.1
      See Also:
      RestResponse, get(String, Map, Map, Authentication)
    • get

      public static final RestResponse get​(java.lang.String uri, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters, Authentication authentication)
      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", "Bearer"
      • Response body - returns the response body if the response is successful. If there is no response, this value will be null.

      Example:

       var uri = "http://example.com/rest/users";
       //set any headers
       var headers = {"Content-Type":"application/json", "Accept":"application/json"};
       //set params
       var params = {"userId":fields.filter.value};
       //create authentication 
       var auth = HttpAuthentication.createBasicAuthentication("username", "password");
       var response = services.rest.get(uri, headers, params, auth);
       if(response.isSuccess())
       {
            var results = JSON.parse(response.getBody());
            if(results)
            {
                 //populate results using the JSON object
                 populateResults(results);
            }
       }
       
      Further documentation.
      Parameters:
      uri - the full URI of the request
      headers - Map of HTTP request headers
      parameters - Map of HTTP request query parameters
      authentication - Authentication object required for HTTP authentication
      Since:
      V5.1
      See Also:
      RestResponse, get(String), get(String, Map, Map), HttpAuthentication
    • get

      public static final RestResponse get​(java.lang.String uri, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters, Authentication authentication, RestOptions options)
      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", "Bearer"
      • Response body - returns the response body if the response is successful. If there is no response, this value will be null.

      Example:

       var uri = "http://example.com/rest/users";
       //set any headers
       var headers = {"Content-Type":"application/json", "Accept":"application/json"};
       //set params
       var params = {"userId":fields.filter.value};
       //create authentication 
       var auth = HttpAuthentication.createBasicAuthentication("username", "password");
       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(uri, headers, params, auth, opts);
       if(response.isSuccess())
       {
            var results = JSON.parse(response.getBody());
            if(results)
            {
                 //populate results using the JSON object
                 populateResults(results);
            }
       }
       
      Further documentation.
      Parameters:
      uri - the full URI of the request
      headers - Map of HTTP request headers
      parameters - Map of HTTP request query parameters
      authentication - Authentication object required for HTTP authentication
      options - rest configuration options RestOptions
      Since:
      V5.1
      See Also:
      RestResponse, get(String), get(String, Map, Map), HttpAuthentication
    • post

      public static final RestResponse post​(java.lang.String uri, java.lang.String body)
      Performs a REST HTTP POST call. Returns a RestResponse representing the response. A POST is used to insert a new resource or can also create a new one if one does not exist.

      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", "Bearer"
      • Response body - returns the response body if the response is successful. If there is no response, this value will be null.

      Example:

       var user = {};
       user.userId = 1;
       user.title = 'foo';
       user.body = 'bar';
       
       var uri = "http://example.com/rest/users";
       var response = services.rest.post(uri, JSON.stringify(user));
       if(response.isSuccess())
       {
            var result = JSON.parse(response.getBody());
            if(result)
            {
                 //populate response using the JSON object
                 displayResult(result);
            }
       }
       
      Further documentation.
      Parameters:
      uri - the full URI of the request
      body - String representation of the HTTP body for the request
      Since:
      V5.1
      See Also:
      RestResponse, post(String, String, Map, Map, Authentication)
    • post

      public static final RestResponse post​(java.lang.String uri, java.lang.String body, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters)
      Performs a REST HTTP POST call supplying any headers and/or parameters required. Returns a RestResponse representing the response. A POST is used to insert a new resource or can also create a new one if one does not exist.

      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", "Bearer"
      • Response body - returns the response body if the response is successful. If there is no response, this value will be null.

      Example:

       var user = {};
       user.userId = 1;
       user.title = 'foo';
       user.body = 'bar';
       
       var uri = "http://example.com/rest/users";
       //set any headers
       var headers = {"Content-Type":"application/json", "Accept":"application/json"};
       //set params
       var params = {"userId":fields.filter.value};
       var response = services.rest.post(uri, JSON.stringify(user), headers, params);
       if(response.isSuccess())
       {
            var result = JSON.parse(response.getBody());
            if(result)
            {
                 //populate response using the JSON object
                 displayResult(result);
            }
       }
       
      Further documentation.
      Parameters:
      uri - the full URI of the request
      body - String representation of the HTTP body for the request
      headers - Map of HTTP request headers
      parameters - Map of HTTP request query parameters
      Since:
      V5.1
      See Also:
      RestResponse, post(String, String, Map, Map, Authentication)
    • post

      public static final RestResponse post​(java.lang.String uri, java.lang.String body, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters, Authentication authentication)
      Performs a REST HTTP POST call supplying any headers and/or parameters required. Returns a RestResponse representing the response. A POST is used to insert a new resource or can also create a new one if one does not exist.

      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", "Bearer"
      • Response body - returns the response body if the response is successful. If there is no response, this value will be null.

      Example:

       var user = {};
       user.userId = 1;
       user.title = 'foo';
       user.body = 'bar';
      
       var uri = "http://example.com/rest/users";
       //set any headers
       var headers = {"Content-Type":"application/json", "Accept":"application/json"};
       //set params
       var params = {"userId":fields.filter.value};
       //create authentication 
       var auth = HttpAuthentication.createBasicAuthentication("username", "password");
       var response = services.rest.post(uri, JSON.stringify(user), headers, params, auth);
       if(response.isSuccess())
       {
            var result = JSON.parse(response.getBody());
            if(result)
            {
                 //populate response using the JSON object
                 displayResult(result);
            }
       }
       
      Further documentation.
      Parameters:
      uri - the full URI of the request
      body - String representation of the HTTP body for the request
      headers - Map of HTTP request headers
      parameters - Map of HTTP request query parameters
      authentication - Authentication object required for HTTP authentication
      Since:
      V5.1
      See Also:
      HttpAuthentication, RestResponse, post(String, String), patch(String, String, Map, Map)
    • post

      public static final RestResponse post​(java.lang.String uri, java.lang.String body, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters, Authentication authentication, RestOptions options)
      Performs a REST HTTP POST call supplying any headers and/or parameters required. Returns a RestResponse representing the response. A POST is used to insert a new resource or can also create a new one if one does not exist.

      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", "Bearer"
      • Response body - returns the response body if the response is successful. If there is no response, this value will be null.

      Example:

       var user = {};
       user.userId = 1;
       user.title = 'foo';
       user.body = 'bar';
      
       var uri = "http://example.com/rest/users";
       //set any headers
       var headers = {"Content-Type":"application/json", "Accept":"application/json"};
       //set params
       var params = {"userId":fields.filter.value};
       //create authentication 
       var auth = HttpAuthentication.createBasicAuthentication("username", "password");
       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);
       var response = services.rest.post(uri, JSON.stringify(user), headers, params, auth, opts);
       if(response.isSuccess())
       {
            var result = JSON.parse(response.getBody());
            if(result)
            {
                 //populate response using the JSON object
                 displayResult(result);
            }
       }
       
      Further documentation.
      Parameters:
      uri - the full URI of the request
      body - String representation of the HTTP body for the request
      headers - Map of HTTP request headers
      parameters - Map of HTTP request query parameters
      authentication - Authentication object required for HTTP authentication
      options - rest configuration options RestOptions
      Since:
      V5.1
      See Also:
      HttpAuthentication, RestResponse, post(String, String), patch(String, String, Map, Map)
    • patch

      public static final RestResponse patch​(java.lang.String uri, java.lang.String body)
      Performs a REST HTTP PATCH call. Returns a RestResponse representing the response. A PATCH call should be used for a partial update to a resource.

      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", "Bearer"
      • Response body - returns the response body if the response is successful. If there is no response, this value will be null.

      Example:

       var user = {};
       user.title = 'foo';
       
       var uri = "http://example.com/rest/users/1";
       var response = services.rest.patch(uri, JSON.stringify(user));
       if(response.isSuccess())
       {
            var result = JSON.parse(response.getBody());
            if(result)
            {
                 //populate response using the JSON object
                 displayResult(result);
            }
       }
       
      Further documentation.
      Parameters:
      uri - the full URI of the request
      body - String representation of the HTTP body for the request
      Since:
      V5.1
      See Also:
      RestResponse, patch(String, String, Map, Map, Authentication)
    • patch

      public static final RestResponse patch​(java.lang.String uri, java.lang.String body, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters)
      Performs a REST HTTP PATCH call supplying any headers and/or parameters required. Returns a RestResponse representing the response. A PATCH call should be used for a partial update to a resource.

      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", "Bearer"
      • Response body - returns the response body if the response is successful. If there is no response, this value will be null.

      Example:

       var user = {};
       user.title = 'foo';
       
       var uri = "http://example.com/rest/users/1";
       //set any headers
       var headers = {"Content-Type":"application/json", "Accept":"application/json"};
       //set params
       var params = {"userId":fields.filter.value};
       var response = services.rest.patch(uri, JSON.stringify(user), headers, params);
       if(response.isSuccess())
       {
            var result = JSON.parse(response.getBody());
            if(result)
            {
                 //populate response using the JSON object
                 displayResult(result);
            }
       }
       
      Further documentation.
      Parameters:
      uri - the full URI of the request
      body - String representation of the HTTP body for the request
      headers - Map of HTTP request headers
      parameters - Map of HTTP request query parameters
      Since:
      V5.1
      See Also:
      RestResponse, patch(String, String, Map, Map, Authentication)
    • patch

      public static final RestResponse patch​(java.lang.String uri, java.lang.String body, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters, Authentication authentication)
      Performs a REST HTTP PATCH call supplying any headers and/or parameters required. Returns a RestResponse representing the response. A PATCH call should be used for a partial update to a resource.

      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", "Bearer"
      • Response body - returns the response body if the response is successful. If there is no response, this value will be null.

      Example:

       var user = {};
       user.title = 'foo';
       
       var uri = "http://example.com/rest/users/1";
       //set any headers
       var headers = {"Content-Type":"application/json", "Accept":"application/json"};
       //set params
       var params = {"userId":fields.filter.value};
       //create authentication 
       var auth = HttpAuthentication.createBasicAuthentication("username", "password");
       var response = services.rest.patch(uri, JSON.stringify(user), headers, params, auth);
       if(response.isSuccess())
       {
            var result = JSON.parse(response.getBody());
            if(result)
            {
                 //populate response using the JSON object
                 displayResult(result);
            }
       }
       
      Further documentation.
      Parameters:
      uri - the full URI of the request
      body - String representation of the HTTP body for the request
      headers - Map of HTTP request headers
      parameters - Map of HTTP request query parameters
      authentication - Authentication object required for HTTP authentication
      Since:
      V5.1
      See Also:
      HttpAuthentication, RestResponse, patch(String, String), patch(String, String, Map, Map)
    • patch

      public static final RestResponse patch​(java.lang.String uri, java.lang.String body, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters, Authentication authentication, RestOptions options)
      Performs a REST HTTP PATCH call supplying any headers and/or parameters required. Returns a RestResponse representing the response. A PATCH call should be used for a partial update to a resource.

      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", "Bearer"
      • Response body - returns the response body if the response is successful. If there is no response, this value will be null.

      Example:

       var user = {};
       user.title = 'foo';
       
       var uri = "http://example.com/rest/users/1";
       //set any headers
       var headers = {"Content-Type":"application/json", "Accept":"application/json"};
       //set params
       var params = {"userId":fields.filter.value};
       //create authentication 
       var auth = HttpAuthentication.createBasicAuthentication("username", "password");
       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);
       var response = services.rest.patch(uri, JSON.stringify(user), headers, params, auth, opts);
       if(response.isSuccess())
       {
            var result = JSON.parse(response.getBody());
            if(result)
            {
                 //populate response using the JSON object
                 displayResult(result);
            }
       }
       
      Further documentation.
      Parameters:
      uri - the full URI of the request
      body - String representation of the HTTP body for the request
      headers - Map of HTTP request headers
      parameters - Map of HTTP request query parameters
      authentication - Authentication object required for HTTP authentication
      options - rest configuration options RestOptions
      Since:
      V5.1
      See Also:
      HttpAuthentication, RestResponse, patch(String, String), patch(String, String, Map, Map)
    • put

      public static final RestResponse put​(java.lang.String uri, java.lang.String body)
      Performs a REST HTTP PUT call. Returns a RestResponse representing the response. A PUT is used to insert a new resource or update an existing one.

      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", "Bearer"
      • Response body - returns the response body if the response is successful. If there is no response, this value will be null.

      Example:

       var user = {};
       user.userId = 1;
       user.title = 'foo';
       user.body = 'bar';
       
       var uri = "http://example.com/rest/users/1";
       var response = services.rest.put(uri, JSON.stringify(user));
       if(response.isSuccess())
       {
            var result = JSON.parse(response.getBody());
            if(result)
            {
                 //populate response using the JSON object
                 displayResult(result);
            }
       }
       
      Further documentation.
      Parameters:
      uri - the full URI of the request
      body - String representation of the HTTP body for the request
      Since:
      V5.1
      See Also:
      RestResponse, put(String, String, Map, Map, Authentication)
    • put

      public static final RestResponse put​(java.lang.String uri, java.lang.String body, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters)
      Performs a REST HTTP PUT call supplying any headers and/or parameters required. Returns a RestResponse representing the response. A PUT is used to insert a new resource or update an existing one.

      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", "Bearer"
      • Response body - returns the response body if the response is successful. If there is no response, this value will be null.

      Example:

       var user = {};
       user.userId = 1;
       user.title = 'foo';
       user.body = 'bar';
       
       var uri = "http://example.com/rest/users";
       //set any headers
       var headers = {"Content-Type":"application/json", "Accept":"application/json"};
       //set params
       var params = {"userId":fields.filter.value};
       var response = services.rest.put(uri, JSON.stringify(user), headers, params);
       if(response.isSuccess())
       {
            var result = JSON.parse(response.getBody());
            if(result)
            {
                 //populate response using the JSON object
                 displayResult(result);
            }
       }
       
      Further documentation.
      Parameters:
      uri - the full URI of the request
      body - String representation of the HTTP body for the request
      headers - Map of HTTP request headers
      parameters - Map of HTTP request query parameters
      Since:
      V5.1
      See Also:
      RestResponse, put(String, String, Map, Map, Authentication)
    • put

      public static final RestResponse put​(java.lang.String uri, java.lang.String body, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters, Authentication authentication)
      Performs a REST HTTP PUT call supplying any headers and/or parameters required. Returns a RestResponse representing the response. A PUT is used to insert a new resource or update an existing one.

      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", "Bearer"
      • Response body - returns the response body if the response is successful. If there is no response, this value will be null.

      Example:

       var user = {};
       user.userId = 1;
       user.title = 'foo';
       user.body = 'bar';
       
       var uri = "http://example.com/rest/users";
       //set any headers
       var headers = {"Content-Type":"application/json", "Accept":"application/json"};
       //set params
       var params = {"userId":fields.filter.value};
       //create authentication 
       var auth = HttpAuthentication.createBasicAuthentication("username", "password");
       var response = services.rest.put(uri, JSON.stringify(user), headers, params, auth);
       if(response.isSuccess())
       {
            var result = JSON.parse(response.getBody());
            if(result)
            {
                 //populate response using the JSON object
                 displayResult(result);
            }
       }
       
      Further documentation.
      Parameters:
      uri - the full URI of the request
      body - String representation of the HTTP body for the request
      headers - Map of HTTP request headers
      parameters - Map of HTTP request query parameters
      authentication - Authentication object required for HTTP authentication
      Since:
      V5.1
      See Also:
      HttpAuthentication, RestResponse, put(String, String), patch(String, String, Map, Map)
    • put

      public static final RestResponse put​(java.lang.String uri, java.lang.String body, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters, Authentication authentication, RestOptions options)
      Performs a REST HTTP PUT call supplying any headers and/or parameters required. Returns a RestResponse representing the response. A PUT is used to insert a new resource or update an existing one.

      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", "Bearer"
      • Response body - returns the response body if the response is successful. If there is no response, this value will be null.

      Example:

       var user = {};
       user.userId = 1;
       user.title = 'foo';
       user.body = 'bar';
       
       var uri = "http://example.com/rest/users";
       //set any headers
       var headers = {"Content-Type":"application/json", "Accept":"application/json"};
       //set params
       var params = {"userId":fields.filter.value};
       //create authentication 
       var auth = HttpAuthentication.createBasicAuthentication("username", "password");
       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);
       var response = services.rest.put(uri, JSON.stringify(user), headers, params, auth, opts);
       if(response.isSuccess())
       {
            var result = JSON.parse(response.getBody());
            if(result)
            {
                 //populate response using the JSON object
                 displayResult(result);
            }
       }
       
      Further documentation.
      Parameters:
      uri - the full URI of the request
      body - String representation of the HTTP body for the request
      headers - Map of HTTP request headers
      parameters - Map of HTTP request query parameters
      authentication - Authentication object required for HTTP authentication
      options - rest configuration options RestOptions
      Since:
      V5.1
      See Also:
      HttpAuthentication, RestResponse, put(String, String), patch(String, String, Map, Map)
    • delete

      public static final RestResponse delete​(java.lang.String uri)
      Performs a REST HTTP DELETE call and returns the HTTP response code. Returns a RestResponse representing the response. A DELETE is used to delete a resource if it exists. The response code returned is 200 if successfully deleted or 404 if the resource does not exist.

      Example:

       var response = services.rest.delete("http://example.com/rest/users/1");
       if(response.isSuccess())
       {
            //display success message
       }
       else
       {
            //display failure message
       }
       
      Further documentation.
      Parameters:
      uri - the full URI of the request
      Since:
      V5.1
      See Also:
      delete(String, Map, Map)
    • delete

      public static final RestResponse delete​(java.lang.String uri, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters)
      Performs a REST HTTP DELETE call and returns the HTTP response code. Returns a RestResponse representing the response. A DELETE is used to delete a resource if it exists. The response code returned is 200 if successfully deleted or 404 if the resource does not exist.

      Example:

       //set any headers
       var headers = {};
       //set params
       var params = {"userId":fields.filter.value};
       var response = services.rest.delete("http://example.com/rest/users", headers, params);
       if(response.isSuccess())
       {
            //display success message
       }
       else
       {
            //display failure message
       }
       
      Further documentation.
      Parameters:
      uri - the full URI of the request
      headers - Map of HTTP request headers
      parameters - Map of HTTP request query parameters
      Since:
      V5.1
      See Also:
      delete(String)
    • delete

      public static final RestResponse delete​(java.lang.String uri, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters, Authentication authentication)
      Performs a REST HTTP DELETE call and returns the HTTP response code. Returns a RestResponse representing the response. A DELETE is used to delete a resource if it exists. The response code returned is 200 if successfully deleted or 404 if the resource does not exist.

      Example:

       //set any headers
       var headers = {};
       //set params
       var params = {"userId":fields.filter.value};
       //create authentication 
       var auth = HttpAuthentication.createBasicAuthentication("username", "password");
       var response = services.rest.delete("http://example.com/rest/users", headers, params, auth);
       if(response.isSuccess())
       {
            //display success message
       }
       else
       {
            //display failure message
       }
       
      Further documentation.
      Parameters:
      uri - the full URI of the request
      headers - Map of HTTP request headers
      parameters - Map of HTTP request query parameters
      authentication - Authentication object required for HTTP authentication
      Since:
      V5.1
      See Also:
      HttpAuthentication, delete(String)
    • delete

      public static final RestResponse delete​(java.lang.String uri, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters, Authentication authentication, RestOptions options)
      Performs a REST HTTP DELETE call and returns the HTTP response code. Returns a RestResponse representing the response. A DELETE is used to delete a resource if it exists. The response code returned is 200 if successfully deleted or 404 if the resource does not exist.

      Example:

       //set any headers
       var headers = {};
       //set params
       var params = {"userId":fields.filter.value};
       //create authentication 
       var auth = HttpAuthentication.createBasicAuthentication("username", "password");
       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);
       var response = services.rest.delete("http://example.com/rest/users", headers, params, auth, opts);
       if(response.isSuccess())
       {
            //display success message
       }
       else
       {
            //display failure message
       }
       
      Further documentation.
      Parameters:
      uri - the full URI of the request
      headers - Map of HTTP request headers
      parameters - Map of HTTP request query parameters
      authentication - Authentication object required for HTTP authentication
      options - rest configuration options RestOptions
      Since:
      V5.1
      See Also:
      HttpAuthentication, delete(String)
    • head

      public static final RestResponse head​(java.lang.String uri)
      Performs a REST HTTP HEAD call on a resource. Returns a RestResponse representing the response. A HEAD is the same as a GET, apart from it does not have a body. This is only used to determine whether a resource is available.

      Example:

       var response = services.rest.head("http://example.com/rest/users");
       if(response.isSuccess())
       {
            //display available message
       }
       else
       {
            //display failure message
       }
       
      Further documentation.
      Parameters:
      uri - the full URI of the request
      Since:
      V5.1
      See Also:
      head(String, Map, Map, Authentication), get(String, Map, Map, Authentication)
    • head

      public static final RestResponse head​(java.lang.String uri, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters)
      Performs a REST HTTP HEAD call on a resource. Returns a RestResponse representing the response. A HEAD is the same as a GET, apart from it does not have a body. This is only used to determine whether a resource is available.

      Example:

       //set any headers
       var headers = {};
       //set params
       var params = {"userId":fields.filter.value};
       var response = services.rest.head("http://example.com/rest/users", headers, params);
       if(response.isSuccess())
       {
            //display available message
       }
       else
       {
            //display failure message
       }
       
      Further documentation.
      Parameters:
      uri - the full URI of the request
      headers - Map of HTTP request headers
      parameters - Map of HTTP request query parameters
      Since:
      V5.1
      See Also:
      head(String, Map, Map, Authentication), get(String, Map, Map, Authentication)
    • head

      public static final RestResponse head​(java.lang.String uri, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters, Authentication authentication)
      Performs a REST HTTP HEAD call on a resource. Returns a RestResponse representing the response. A HEAD is the same as a GET, apart from it does not have a body. This is only used to determine whether a resource is available.

      Example:

       //set any headers
       var headers = {};
       //set params
       var params = {"userId":fields.filter.value};
       //create authentication 
       var auth = HttpAuthentication.createBasicAuthentication("username", "password");
       var response = services.rest.head("http://example.com/rest/users", headers, params, auth);
       if(response.isSuccess())
       {
            //display available message
       }
       else
       {
            //display failure message
       }
       
      Further documentation.
      Parameters:
      uri - the full URI of the request
      headers - Map of HTTP request headers
      parameters - Map of HTTP request query parameters
      authentication - Authentication object required for HTTP authentication
      Since:
      V5.1
      See Also:
      get(String, Map, Map, Authentication), HttpAuthentication
    • head

      public static final RestResponse head​(java.lang.String uri, java.util.Map<java.lang.String,​java.lang.Object> headers, java.util.Map<java.lang.String,​java.lang.Object> parameters, Authentication authentication, RestOptions options)
      Performs a REST HTTP HEAD call on a resource. Returns a RestResponse representing the response. A HEAD is the same as a GET, apart from it does not have a body. This is only used to determine whether a resource is available.

      Example:

       //set any headers
       var headers = {};
       //set params
       var params = {"userId":fields.filter.value};
       //create authentication 
       var auth = HttpAuthentication.createBasicAuthentication("username", "password");
       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);
       var response = services.rest.head("http://example.com/rest/users", headers, params, auth, opts);
       if(response.isSuccess())
       {
            //display available message
       }
       else
       {
            //display failure message
       }
       
      Further documentation.
      Parameters:
      uri - the full URI of the request
      headers - Map of HTTP request headers
      parameters - Map of HTTP request query parameters
      authentication - Authentication object required for HTTP authentication
      options - rest configuration options RestOptions
      Since:
      V5.1
      See Also:
      get(String, Map, Map, Authentication), HttpAuthentication
    • accessMethods

      public static final java.lang.String[] accessMethods​(java.lang.String uri)
      Returns an array of available HTTP methods to a resource after a HTTP OPTIONS call. e.g GET, POST

      Example:

       var uri = "http://example.com/rest/users";
       var results = services.rest.accessMethods(uri);
       if(results)
       {
         var list = fields.options.createCustomList();
         for each(var x in results)
         {
            list.add(x);
         }
       }
       
      Further documentation.
      Parameters:
      uri - the full URI of the request
      Since:
      V5.1
    • accessMethods

      public static final java.lang.String[] accessMethods​(java.lang.String uri, Authentication authentication)
      Returns an array of available HTTP methods to a resource after a HTTP OPTIONS call. e.g GET, POST

      Example:

       var uri = "http://example.com/rest/users";
       //create authentication 
       var auth = HttpAuthentication.createBasicAuthentication("username", "password");
       var results = services.rest.accessMethods(uri, auth);
       if(results)
       {
         var list = fields.options.createCustomList();
         for each(var x in results)
         {
            list.add(x);
         }
       }
       
      Further documentation.
      Parameters:
      uri - the full URI of the request
      authentication - Authentication object required for HTTP authentication
      Since:
      V5.1
      See Also:
      HttpAuthentication
    • accessMethods

      public static final java.lang.String[] accessMethods​(java.lang.String uri, Authentication authentication, RestOptions options)
      Returns an array of available HTTP methods to a resource after a HTTP OPTIONS call. e.g GET, POST

      Example:

       var uri = "http://example.com/rest/users";
       //create authentication 
       var auth = HttpAuthentication.createBasicAuthentication("username", "password");
       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);
       var results = services.rest.accessMethods(uri, auth, opts);
       if(results)
       {
         var list = fields.options.createCustomList();
         for each(var x in results)
         {
            list.add(x);
         }
       }
       
      Further documentation.
      Parameters:
      uri - the full URI of the request
      authentication - Authentication object required for HTTP authentication
      options - rest configuration options RestOptions
      Since:
      V5.1
      See Also:
      HttpAuthentication
    • options

      public static final RestResponse options​(java.lang.String uri)
      Performs a REST HTTP OPTIONS call and returns the HTTP response code. Returns a RestResponse representing the response.

      Example:

       var uri = "http://example.com/rest/users";
       var response = services.rest.options(uri);
       if(response.isSuccess())
       {
         var allowed = response.getHeaders()['Allow'];
         if(allowed)
         {
           var results = allowed.split(',');
           var list = fields.options.createCustomList();
           for each(var x in results)
           {
              list.add(x);
           }
         }
       }
       
      Further documentation.
      Parameters:
      uri - the full URI of the request
      Since:
      V5.1
    • options

      public static final RestResponse options​(java.lang.String uri, Authentication authentication)
      Performs a REST HTTP OPTIONS call and returns the HTTP response code. Returns a RestResponse representing the response.

      Example:

       var uri = "http://example.com/rest/users";
       //create authentication 
       var auth = HttpAuthentication.createBasicAuthentication("username", "password");
       var response = services.rest.options(uri, auth);
       if(response.isSuccess())
       {
         var allowed = response.getHeaders()['Allow'];
         if(allowed)
         {
           var results = allowed.split(',');
           var list = fields.options.createCustomList();
           for each(var x in results)
           {
              list.add(x);
           }
         }
       }
       
      Further documentation.
      Parameters:
      uri - the full URI of the request
      authentication - Authentication object required for HTTP authentication
      Since:
      V5.1
      See Also:
      HttpAuthentication
    • options

      public static final RestResponse options​(java.lang.String uri, Authentication authentication, RestOptions options)
      Performs a REST HTTP OPTIONS call and returns the HTTP response code. Returns a RestResponse representing the response.

      Example:

       var uri = "http://example.com/rest/users";
       //create authentication 
       var auth = HttpAuthentication.createBasicAuthentication("username", "password");
       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);
       var response = services.rest.options(uri, auth, opts);
       if(response.isSuccess())
       {
         var allowed = response.getHeaders()['Allow'];
         if(allowed)
         {
           var results = allowed.split(',');
           var list = fields.options.createCustomList();
           for each(var x in results)
           {
              list.add(x);
           }
         }
       }
       
      Further documentation.
      Parameters:
      uri - the full URI of the request
      authentication - Authentication object required for HTTP authentication
      options - rest configuration options RestOptions
      Since:
      V5.1
      See Also:
      HttpAuthentication
    • getLocalUrlBase

      public static final java.lang.String getLocalUrlBase()
      Returns a base URL to invoke a RESTful service on this server using localhost i.e. returns a URL of the type: http://127.0.0.1:<port>/<webapp>/api

      Example:

       var endpoint = "/orders/getOrders";
       var url = services.rest.getLocalUrlBase() + endpoint;
       var response = services.rest.get(url);
       
      Since:
      V5.2