Package com.ebasetech.xi.services
Interface RestResponse
public interface RestResponse
RestResponse contains the following response information following a RestServices call:
- HTTP Code - HTTP Response code return from the
RestServicescall - Response Headers - All the HTTP response headers as key-->value String pairs
- Body - A String representation of the response body
RestServices- Since:
- V5.1
-
Method Summary
Modifier and Type Method Description java.lang.StringgetBody()Returns the response body as a string representation following aRestServicescallintgetCode()Returns the HTTP response code following aRestServicescalljava.util.Map<java.lang.String,java.lang.String>getHeaders()Returns the response headers as key-->value string pairs following aRestServicescall The key-->value pairs are returned as a JavaScript object.booleanisSuccess()Returns whether response code is successful following aRestServicescall.
-
Method Details
-
getCode
int getCode()Returns the HTTP response code following aRestServicescall- Since:
- V5.1
- See Also:
RestServices
-
getHeaders
java.util.Map<java.lang.String,java.lang.String> getHeaders()Returns the response headers as key-->value string pairs following aRestServicescall The key-->value pairs are returned as a JavaScript object. Accessing a key value where the name of the key has a hyphen in it needs to be accessed using headers["key-name"] syntax.Example:
var response = services.rest.get("http://example.com/rest/users"); var headers = response.getHeaders(); var content = headers["Content-Type"]; if(content == 'application/json') { //do something with JSON }- Since:
- V5.1
- See Also:
RestServices
-
getBody
java.lang.String getBody()Returns the response body as a string representation following aRestServicescallThe response body also contains the error message from a response if it is an unsuccessful call.
Example:
var response = services.rest.get("http://example.com/rest/users"); if(response.isSuccess()) { var results = JSON.parse(response.getBody()); if(results) { //do something with the results } } else { event.getOwner().addErrorMessage(response.getBody()); }- Since:
- V5.1
- See Also:
RestServices
-
isSuccess
boolean isSuccess()Returns whether response code is successful following aRestServicescall. A successful response code is in the HTTP 200 range.Example:
var response = services.rest.get("http://example.com/rest/users"); if(response.isSuccess()) { //do something } else { //show error }- Since:
- V5.1
- See Also:
RestServices
-