Versions Compared
compared with
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Comment:
Merged branch "DOC0000089" into parent
This server class allows operating with REST responses.
SimpleRestResponse(response)
Initialises an empty SimpleRestResponse objectObjects of this class are created within invoking the execute() method of the SimpleRestRequest server-side class.
Name | Type | Mandatory | Default Value |
---|---|---|---|
response | Response | Y | N |
Return:
Type | Description |
---|---|
Void | This method does not return a value. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
constvar smrequest = sws.SimpleRestResponse(response.restRequestV1(); request.setRequestUrl('https://jsonplaceholder.typicode.com/todos/1'); request.setRequestMethod('GET'); const response = request.execute(); |
getBody()
This method returns the response body.
Return:
Type | Description |
---|---|
String | The response body. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
varconst smrequest = sws.SimpleRestResponse(response.restRequestV1(); request.setRequestUrl('https://jsonplaceholder.typicode.com/todos/1'); request.setRequestMethod('GET'); varconst bodyresponse = smrequest.execute(); ss.info(response.getBody()); // Info: { // "userId": 1, // "id": 1, // "title": "delectus aut autem", // "completed": false // } |
getAllHeaders()
This method returns the array containing response headers.
Return:
Type | Description |
---|---|
ArrayObject | Response headers. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
varconst smrequest = sws.SimpleRestResponse(response.restRequestV1(); request.setRequestUrl('https://jsonplaceholder.typicode.com/todos/1'); request.setRequestMethod('GET'); varconst headersresponse = smrequest.execute(); ss.info(response.getAllHeaders()); // Info: {"http-code":["200"],"date":["Mon, 31... |
getStatusCode()
Returns This method returns the HTTP status code of the request performed.
Return:
Type | Description |
---|---|
String | HTTP status code. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
constvar smrequest = sws.SimpleRestResponse(response.restRequestV1(); request.setRequestUrl('https://jsonplaceholder.typicode.com/todos/1'); request.setRequestMethod('GET'); varconst statusresponse = smrequest.execute(); ss.info(response.getStatusCode()); // Info: 200 |
haveError()
This method displays if there was an error during the REST transaction.
Return:
Type | Description |
---|---|
Boolean | The error notification. |
Example:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
constvar smrequest = sws.SimpleRestResponse(response.restRequestV1(); request.setRequestUrl('https://jsonplaceholder.typicode.com/todos/1'); request.setRequestMethod('GET'); varconst errorresponse = smrequest.execute(); ss.info(response.haveError()); // Info: false |
Table of Contents | ||||
---|---|---|---|---|
|