Consuming a REST Web Service can be done using the methods found in the JavaScript services.rest
API.
For each of the common HTTP Methods, GET, POST, PUT, DELETE, HEAD and PATCH, there is a corresponding JavaScript Method. For example, the services.rest.get()
will send a HTTP Request with a GET Method and return a response object.
var responseObject = services.rest.get("http://verjtraining.verj.cloud/apps/api/coin/flip");
The services.rest API request methods have optional arguments which include body (if applicable), request headers, request parameters, authorization and REST options.
The response object that is returned by a services.rest
HTTP request has the following attributes:
- body the response body
- code the response status code
- headers the response headers
- success indicates request success
To view these attributes in your logs you will need to use the log()
function. There is no debug feature when calling a REST Web Service using the services.rest
API.