Skip to main content

Reference

 

OutSystems

REST Extensibility API for Java

The OutSystems REST Extensibility API enables you to access the content of requests and responses used by methods consumed from other REST APIs. It is automatically imported to your environment at installation.

To manipulate the request/response, create an extension module, and use its methods in the OnBeforeRequestAdvanced/OnAfterResponseAdvanced callback of the consumed REST API. Learn more about how to customize the request/response.

The components described in this topic are available in the following package: outsystems.runtimepublic.rest

To see examples of how to use them, look for modules that use REST APIs in the Components category of OutSystems Forge.

RestRequest Class

This object provides low-level access to the request objects used when executing methods of consumed REST APIs.

Methods

Name Description
static RestRequest getCurrent() Returns the request object used by methods consumed from REST APIs. Should only be used inside the OnBeforeRequestAdvanced callback, otherwise null is returned.
Example: to obtain the instance of this class, use RestRequest.getCurrent().
String getActionName() Returns the name of the method consumed from REST APIs that invoked the extension.
HttpClient getHttpClient() Returns the native HttpClient object used to execute the web request.
HttpUriRequest getHttpUriRequest() Returns the native HttpUriRequest object used to execute the web request.
byte[] getRequestBodyAsBinary() Returns the message body of the web request as binary content.
String getRequestBodyAsText() Returns the message body of the web request as a string.
void setRequestBody(byte[] bytes) Sets the message body of the web request with binary content.
void setRequestBody(String text) Sets the message body of the web request with text. If the method has its 'Request Format' property set to 'Binary', no changes are made to the message body.
void setHttpClient(HttpClient httpClient) Sets the native HttpClient object used to execute the web request.

RestResponse Class

This object provides low-level access to the response objects when executing methods of the consumed REST API.

Methods

Name Description
static RestResponse getCurrent() Returns the response object used by methods consumed from REST APIs. Should only be used inside the OnAfterResponseAdvanced callback, otherwise null is returned.
Example: to obtain the instance of this class, use RestResponse.getCurrent().
String getActionName() Returns the name of the method consumed from REST APIs that invoked the extension.
HttpClient getHttpClient() Returns the native HttpClient object that resulted from the web request.
HttpResponse getHttpResponse() Returns the native HttpResponse object that resulted from the web request.
byte[] getResponseBodyAsBinary() Returns the message body of the web response as binary content.
String getResponseBodyAsText() Returns the message body of the web response as a string.
void setResponseBody(byte[] bytes) Sets the message body of the web response with binary content.
void setResponseBody(String text) Sets the message body of the web response with text. If the method has its 'Response Format' property set to 'Binary', no changes are made to the message body.
  • Was this article helpful?