Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Merged branch "feedback" into parent

This class allows to perform access scripted Methods of this class allow getting access to the Scripted REST API request details in scripts. 

body

The body of the request.

within your scripts.

Note

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. 


Name

TypebodyArray

Example:

Code Block
languagexmljs
themeEclipse
titlebodygetBody
linenumberstrue
[(function(request, response) {
    // Send JSON-formatted request to
   'sys_id' => '1234567890',
   'name' => 'incident'
]
getHeader
 // 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:

Type
getHeader
Description
StringThis method returns the specified header value.

Re

 For more clarity, check the example below

Example:

Code Block
languagejs
themeEclipse
titlegetHeader
linenumberstrue
const acceptHeader(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('acceptcontent-type');
headers
 // application/json
})(SimpleApiRequest, SimpleApiResponse)


getHeaders()


This method allows defining all request headers and their values.

Name


Return:

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


Example:

Code Block
languagexmljs
themeEclipse
titleheadersgetHeaders
linenumberstrue
[
   'content-type' => 'Application/json'
]

queryParams

(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 The query parameters from the request.

Field


Return:

Type
queryParamsArray
Description
Array This method returns array of values containing query parameters. 


Example:

Code Block
languagejs
themeEclipse
titlegetQueryParams
linenumberstrue
(function(request, response) {
    // Send Request to 
    //Source request URL: https://your-instance-url.simpleone.ru/apiv1/now/table/myTable?active=false&name=now
[c_simple/api_module_path/api_action_path?param_1=value_1

   'active' =>const false
queryParamsObject =  'name' => 'now'
]

queryString

request.getQueryParams(); // {"param_1":"value_1"}
})(SimpleApiRequest, SimpleApiResponse)


getQueryString()


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

Field


Return:

TypeDescription
queryStringArray
StringThis method return a query string.


Example:

Code Block
languagejs
themeEclipse
titlegetQueryParams
(function(request, response) {
    // Send Request to 
    //Source request URL: https://your-instance-url.simpleone.ru/apiv1/now/table/myTable?active=false&name=now
[
   active=false&name=now
]

uri

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 The request URI with the domain information excluded.

Field


Return:

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


Example:

Code Block
languagexmljs
themeEclipse
titleURIgetUri
linenumberstrue
const query(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.urigetUri(); // /v1/"api/now/table/myTable"	
Source request URL:c_simple/api_module_path/api_action_path
})(SimpleApiRequest, SimpleApiResponse) 


Code Block
languagejs
themeEclipse
titlegetUri
linenumberstrue
(function(request, response) {
    // Send Request to 
    // https://your-instance-url.simpleone.ru/api/now/table/myTable?active=false&name=now.

url



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


getUrl()


This method returns the The entire request URL.

Field


Return:

Type
url
Description
StringThis method returns the request URL.


Example:

Code Block
languagexmljs
themeEclipse
titleURLgetUrl
linenumberstrue
const query = request.url; //"(function(request, response) {
    // Send Request to 
    // https://your-instance-url.simpleone.ru/v1/api/now/table/myTable?active=false&name=now"
Source request URL: https://instancec_simple/api_module_path/api_action_path?param_1=value_1

    const URL = request.getUrl(); // http://your-instance-url.simpleone.ru/apiv1/now/table/myTable?active=false&name=now.c_simple/api_module_path/api_action_path
})(SimpleApiRequest, SimpleApiResponse)


Table of Contents
absoluteUrltrue
classfixedPosition