Methods of this class allow getting access to the Scripted REST API request details within your scripts.

Objects of this type cannot be instantiated and created automatically. They are accessible within the API action script body by the request variable. 

For more information, please refer to the Configuring Scripted REST API article.

getBody()


This method allows returning the request body.


Return:

TypeDescription
ObjectThe body of the request. 


Example:

getBody
(function(request, response) {
    // Send 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)


Returns the value of the header specified.

Parameters:

NameTypeMandatoryDefault value
headerStringYN

Return:

TypeDescription
StringThis method returns the specified header value.

Re

 For more clarity, check the example below

Example:

getHeader
(function(request, response) {
    // Send 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()


This method allows defining all request headers and their values.

Return:

TypeDescription
Array of strings This method returns array of strings containing all request headers.

Example:

getHeaders
(function(request, response) {
    // Send 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()


This method returns the query parameters from the request.

Return:

TypeDescription
Array This method returns array of values containing query parameters. 

Example:

getQueryParams
(function(request, response) {
    // Send 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()


This method returns the entire query added to the endpoint URL.

Return:

TypeDescription
StringThis method return a query string.

Example:

getQueryParams
(function(request, response) {
    // Send 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()


This method returns the request URI with the domain information excluded.


Return:

TypeDescription
String or NullThis method returns the request URI. If no path has been passed after the domain name, then the method returns 'null'


Example:

getUri
(function(request, response) {
    // Send 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 Request to 
    // https://your-instance-url.simpleone.ru/

    const URI = request.getUri(); // null
})(SimpleApiRequest, SimpleApiResponse) 


getUrl()


This method returns the entire request URL.


Return:

TypeDescription
StringThis method returns the request URL.


Example:

getUrl
(function(request, response) {
    // Send 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