You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 9 Next »

This server class allows operating with REST responses.

SimpleRestResponse(response)


Objects of this class are created within invoking the execute() method of the SimpleRestRequest server-side class.
NameTypeMandatoryDefault Value
responseResponseYN


Return:

TypeDescription
VoidThis method does not return a value.


Example:

SimpleRestResponse
const request = sws.restRequestV1();
request.setRequestUrl('https://jsonplaceholder.typicode.com/todos/1');
request.setRequestMethod('GET');
const response = request.execute();

getBody()


This method returns the response body.


Return:

TypeDescription
StringThe response body.


Example:

getBody
const request = sws.restRequestV1();
request.setRequestUrl('https://jsonplaceholder.typicode.com/todos/1');
request.setRequestMethod('GET');
const response = request.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:

TypeDescription
ObjectResponse headers.


Example:

getAllHeaders
const request = sws.restRequestV1();
request.setRequestUrl('https://jsonplaceholder.typicode.com/todos/1');
request.setRequestMethod('GET');
const response = request.execute();
ss.info(response.getAllHeaders());
// Info: {"http-code":["200"],"date":["Mon, 31...

getStatusCode()


This method returns the HTTP status code of the request performed.


Return:

TypeDescription
StringHTTP status code.


Example:

getStatusCode
const request = sws.restRequestV1();
request.setRequestUrl('https://jsonplaceholder.typicode.com/todos/1');
request.setRequestMethod('GET');
const response = request.execute();
ss.info(response.getStatusCode());
// Info: 200

haveError()


This method displays if there was an error during the REST transaction.


Return:

TypeDescription
BooleanThe error notification.


Example:

haveError
const request = sws.restRequestV1();
request.setRequestUrl('https://jsonplaceholder.typicode.com/todos/1');
request.setRequestMethod('GET');
const response = request.execute();
ss.info(response.haveError());
// Info: false

  • No labels