Versions Compared
compared with
Key
- This line was added.
- This line was removed.
- Formatting was changed.
This class helps you to create a REST response to a scripted REST API Request.
setBody(body)
Sets the response content.
Parameter:
Name | Type | Mandatory | Default Value |
---|---|---|---|
body | Object | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
let body = {}; body.name = ""'incident""'; body.number = ""'1234""'; body.caller = {""'id""': ""'user1""'}; response.setBody(body); |
setHeader(header, value)
This method allows to assign a value to a REST service response header.
Parameters:
Name | Type | Mandatory | Default Value |
---|---|---|---|
header | String | Y | N |
value | String | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
response.setHeader("Location","<URI>"); |
setHeaders(headers)
Sets the headers for the web service response.
Parameters:
Name | Type | Mandatory | Default Value |
---|---|---|---|
headers | Object | Y | N |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
let headers = {}; headers.X-Total-Count=100; headers.Location=‘https'https://instance.simpleone.ru/<endpoint_to_resource>'; response.setHeaders(headers); |
setStatus(status)
This method sets the status code number for the service response.
Parameters:
Name | Type | Mandatory | Default Value |
---|---|---|---|
Status | Integer | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
response.setStatus(200); |