The class provides methods that get access to the Scripted REST API request details within scripts.
Object instances of this type are available as a request variable in the API Action script body.
See the Scripted REST API article to learn more.
getBody()
Use the method to get the request body.
Return:
Type | Description |
---|---|
Any | This method returns the request body. |
Example:
(function(request, response) { // Send the JSON-formatted request to // https://your-instance-url.simpleone.ru/v1/c_simple/api_module_path/api_action_path const requestBody = request.getBody(); // {"key":"value"} })(SimpleApiRequest, SimpleApiResponse)
getHeader(header)
Use the method to get the value of the specified request header.
Parameter(s):
Name | Type | Mandatory | Default value |
---|---|---|---|
header | String | Y | N |
Return:
Type | Description |
---|---|
Any | This method returns the value of the specified header. |
Example:
(function(request, response) { // Send the JSON-formatted request to // https://your-instance-url.simpleone.ru/v1/c_simple/api_module_path/api_action_path const contentType = request.getHeader('content-type'); // application/json })(SimpleApiRequest, SimpleApiResponse)
getHeaders()
Use the method to get the values of all request headers.
Return:
Type | Description |
---|---|
Object | This method returns the object that contains the keys – the header names. |
Example:
(function(request, response) { // Send the request to // https://your-instance-url.simpleone.ru/v1/c_simple/api_module_path/api_action_path const allHeaders = request.getHeaders(); // {"accept-encoding":["gzip, deflate, br"],"postman-token":...} })(SimpleApiRequest, SimpleApiResponse)
getQueryParams()
Use the method to get the request parameters.
Return:
Type | Description |
---|---|
Object | This method returns the object that contains the keys – the request parameters. |
Example:
(function(request, response) { // Send the request to // https://your-instance-url.simpleone.ru/v1/c_simple/api_module_path/api_action_path?param_1=value_1 const queryParamsObject = request.getQueryParams(); // {"param_1":"value_1"} })(SimpleApiRequest, SimpleApiResponse)
getQueryString()
Use the method to get the request parameters as a string.
Return:
Type | Description |
---|---|
String | This method returns the request parameters. |
Example:
(function(request, response) { // Send the request to // https://your-instance-url.simpleone.ru/v1/c_simple/api_module_path/api_action_path?param_1=value_1 const queryParamsString = request.getQueryString(); // param_1=value_1 })(SimpleApiRequest, SimpleApiResponse)
getUri()
Use this method to get the request URI without the domain.
Return:
Type | Description |
---|---|
String | This method returns the request URI запроса. If no path is passed after the domain name, the method returns null. |
Examples:
(function(request, response) { // Send the request to // https://your-instance-url.simpleone.ru/v1/c_simple/api_module_path/api_action_path?param_1=value_1 const URI = request.getUri(); // /v1/api/c_simple/api_module_path/api_action_path })(SimpleApiRequest, SimpleApiResponse)
(function(request, response) { // Send the request to // https://your-instance-url.simpleone.ru/ const URI = request.getUri(); // null })(SimpleApiRequest, SimpleApiResponse)
getUrl()
Use the method to get the full request URL.
Return:
Type | Description |
---|---|
String | This method returns the full request URL. |
Example:
(function(request, response) { // Send the request to // https://your-instance-url.simpleone.ru/v1/api/c_simple/api_module_path/api_action_path?param_1=value_1 const URL = request.getUrl(); // http://your-instance-url.simpleone.ru/v1/c_simple/api_module_path/api_action_path })(SimpleApiRequest, SimpleApiResponse)
- No labels