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:
| Constructor and Description |
|---|
RestServices() |
| Modifier and Type | Method and 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.
|
public static final RestResponse get(java.lang.String uri)
RestResponse representing the response. A GET is a read only call.
RestResponse contains the following data:
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.uri - the full URI of the requestRestResponse,
get(String, Map, Map, Authentication)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)
RestResponse representing the response.
A GET is a read only call.
RestResponse contains the following data:
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.uri - the full URI of the requestheaders - Map of HTTP request headersparameters - Map of HTTP request query parametersRestResponse,
get(String, Map, Map, Authentication)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)
RestResponse representing the response.
A GET is a read only call.
RestResponse contains the following data:
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.uri - the full URI of the requestheaders - Map of HTTP request headersparameters - Map of HTTP request query parametersauthentication - Authentication object required for HTTP authenticationRestResponse,
get(String),
get(String, Map, Map),
HttpAuthenticationpublic 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)
RestResponse representing the response.
A GET is a read only call.
RestResponse contains the following data:
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.uri - the full URI of the requestheaders - Map of HTTP request headersparameters - Map of HTTP request query parametersauthentication - Authentication object required for HTTP authenticationoptions - rest configuration options RestOptionsRestResponse,
get(String),
get(String, Map, Map),
HttpAuthenticationpublic static final RestResponse post(java.lang.String uri, java.lang.String body)
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:
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.uri - the full URI of the requestbody - String representation of the HTTP body for the requestRestResponse,
post(String, String, Map, Map, Authentication)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)
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:
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.uri - the full URI of the requestbody - String representation of the HTTP body for the requestheaders - Map of HTTP request headersparameters - Map of HTTP request query parametersRestResponse,
post(String, String, Map, Map, Authentication)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)
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:
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.uri - the full URI of the requestbody - String representation of the HTTP body for the requestheaders - Map of HTTP request headersparameters - Map of HTTP request query parametersauthentication - Authentication object required for HTTP authenticationHttpAuthentication,
RestResponse,
post(String, String),
patch(String, String, Map, Map)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)
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:
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.uri - the full URI of the requestbody - String representation of the HTTP body for the requestheaders - Map of HTTP request headersparameters - Map of HTTP request query parametersauthentication - Authentication object required for HTTP authenticationoptions - rest configuration options RestOptionsHttpAuthentication,
RestResponse,
post(String, String),
patch(String, String, Map, Map)public static final RestResponse patch(java.lang.String uri, java.lang.String body)
RestResponse representing the response. A PATCH call should be
used for a partial update to a resource.
RestResponse contains the following data:
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.uri - the full URI of the requestbody - String representation of the HTTP body for the requestRestResponse,
patch(String, String, Map, Map, Authentication)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)
RestResponse representing the response.
A PATCH call should be used for a partial update to a resource.
RestResponse contains the following data:
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.uri - the full URI of the requestbody - String representation of the HTTP body for the requestheaders - Map of HTTP request headersparameters - Map of HTTP request query parametersRestResponse,
patch(String, String, Map, Map, Authentication)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)
RestResponse representing the response.
A PATCH call should be used for a partial update to a resource.
RestResponse contains the following data:
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.uri - the full URI of the requestbody - String representation of the HTTP body for the requestheaders - Map of HTTP request headersparameters - Map of HTTP request query parametersauthentication - Authentication object required for HTTP authenticationHttpAuthentication,
RestResponse,
patch(String, String),
patch(String, String, Map, Map)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)
RestResponse representing the response.
A PATCH call should be used for a partial update to a resource.
RestResponse contains the following data:
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.uri - the full URI of the requestbody - String representation of the HTTP body for the requestheaders - Map of HTTP request headersparameters - Map of HTTP request query parametersauthentication - Authentication object required for HTTP authenticationoptions - rest configuration options RestOptionsHttpAuthentication,
RestResponse,
patch(String, String),
patch(String, String, Map, Map)public static final RestResponse put(java.lang.String uri, java.lang.String body)
RestResponse representing the response. A PUT is used to insert a new resource
or update an existing one.
RestResponse contains the following data:
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.uri - the full URI of the requestbody - String representation of the HTTP body for the requestRestResponse,
put(String, String, Map, Map, Authentication)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)
RestResponse representing the response.
A PUT is used to insert a new resource or update an existing one.
RestResponse contains the following data:
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.uri - the full URI of the requestbody - String representation of the HTTP body for the requestheaders - Map of HTTP request headersparameters - Map of HTTP request query parametersRestResponse,
put(String, String, Map, Map, Authentication)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)
RestResponse representing the response.
A PUT is used to insert a new resource or update an existing one.
RestResponse contains the following data:
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.uri - the full URI of the requestbody - String representation of the HTTP body for the requestheaders - Map of HTTP request headersparameters - Map of HTTP request query parametersauthentication - Authentication object required for HTTP authenticationHttpAuthentication,
RestResponse,
put(String, String),
patch(String, String, Map, Map)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)
RestResponse representing the response.
A PUT is used to insert a new resource or update an existing one.
RestResponse contains the following data:
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.uri - the full URI of the requestbody - String representation of the HTTP body for the requestheaders - Map of HTTP request headersparameters - Map of HTTP request query parametersauthentication - Authentication object required for HTTP authenticationoptions - rest configuration options RestOptionsHttpAuthentication,
RestResponse,
put(String, String),
patch(String, String, Map, Map)public static final RestResponse delete(java.lang.String uri)
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.uri - the full URI of the requestdelete(String, Map, Map)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)
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.uri - the full URI of the requestheaders - Map of HTTP request headersparameters - Map of HTTP request query parametersdelete(String)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)
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.uri - the full URI of the requestheaders - Map of HTTP request headersparameters - Map of HTTP request query parametersauthentication - Authentication object required for HTTP authenticationHttpAuthentication,
delete(String)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)
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.uri - the full URI of the requestheaders - Map of HTTP request headersparameters - Map of HTTP request query parametersauthentication - Authentication object required for HTTP authenticationoptions - rest configuration options RestOptionsHttpAuthentication,
delete(String)public static final RestResponse head(java.lang.String uri)
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.uri - the full URI of the requesthead(String, Map, Map, Authentication),
get(String, Map, Map, Authentication)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)
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.uri - the full URI of the requestheaders - Map of HTTP request headersparameters - Map of HTTP request query parametershead(String, Map, Map, Authentication),
get(String, Map, Map, Authentication)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)
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.uri - the full URI of the requestheaders - Map of HTTP request headersparameters - Map of HTTP request query parametersauthentication - Authentication object required for HTTP authenticationget(String, Map, Map, Authentication),
HttpAuthenticationpublic 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)
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.uri - the full URI of the requestheaders - Map of HTTP request headersparameters - Map of HTTP request query parametersauthentication - Authentication object required for HTTP authenticationoptions - rest configuration options RestOptionsget(String, Map, Map, Authentication),
HttpAuthenticationpublic static final java.lang.String[] accessMethods(java.lang.String uri)
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.uri - the full URI of the requestpublic static final java.lang.String[] accessMethods(java.lang.String uri,
Authentication authentication)
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.uri - the full URI of the requestauthentication - Authentication object required for HTTP authenticationHttpAuthenticationpublic static final java.lang.String[] accessMethods(java.lang.String uri,
Authentication authentication,
RestOptions options)
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.uri - the full URI of the requestauthentication - Authentication object required for HTTP authenticationoptions - rest configuration options RestOptionsHttpAuthenticationpublic static final RestResponse options(java.lang.String uri)
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.uri - the full URI of the requestpublic static final RestResponse options(java.lang.String uri, Authentication authentication)
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.uri - the full URI of the requestauthentication - Authentication object required for HTTP authenticationHttpAuthenticationpublic static final RestResponse options(java.lang.String uri, Authentication authentication, RestOptions options)
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.uri - the full URI of the requestauthentication - Authentication object required for HTTP authenticationoptions - rest configuration options RestOptionsHttpAuthenticationpublic static final java.lang.String getLocalUrlBase()
Example:
var endpoint = "/orders/getOrders"; var url = services.rest.getLocalUrlBase() + endpoint; var response = services.rest.get(url);