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:

TypeDescription
AnyThis method returns the request body.

Example:

getBody()
(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):

NameTypeMandatoryDefault value
headerStringYN

Return:

TypeDescription
AnyThis method returns the value of the specified header.

Example:

getHeader()
(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:

TypeDescription
Object This method returns the object that contains the keys – the header names.

Example:

getHeaders()
(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:

TypeDescription
ObjectThis method returns the object that contains the keys – the request parameters.

Example:

getQueryParams()
(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:

TypeDescription
StringThis method returns the request parameters.

Example:

getQueryString()
(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:

TypeDescription
String

This method returns the request URI запроса. If no path is passed after the domain name, the method returns null

Examples:

getUri()
(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) 
getUri()
(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:

TypeDescription
StringThis method returns the full request URL.

Example:

getUrl()
(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