Versions Compared

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 object
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:

Code Block
languagejs
themeEclipse
titleSimpleRestResponse
linenumberstrue
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:

TypeDescription
StringThe response body.


Example:

Code Block
languagejs
themeEclipse
titlegetBody
linenumberstrue
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:

TypeDescription
ArrayObjectResponse headers.


Example:

Code Block
languagejs
themeEclipse
titlegetAllHeaders
linenumberstrue
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:

TypeDescription
StringHTTP status code.


Example:

Code Block
languagejs
themeEclipse
titlegetStatusCode
linenumberstrue
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:

TypeDescription
BooleanThe error notification.


Example:

Code Block
languagejs
themeEclipse
titlehaveError
linenumberstrue
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
absoluteUrltrue
classfixedPosition