SimpleRestRequest
This server class provides methods to work with the REST API methods and parameters.
SimpleRestRequest object
To create a SimpleRestRequest object, use the sws.restRequestV1 method as described below.
Parameter(s):
Name | Type | Mandatory | Default value |
---|---|---|---|
requestName | String | N | '' |
methodName | String | N | '' |
note
Provide values for parameters as shown below:
Parameter | Value |
---|---|
requestName | Specify the value of the Name field taken from the record in the REST Requests (sys_rest_requests) table. |
methodName | Specify the value of the Name field taken from the record in the REST Request Methods (sys_rest_request_method) table related with this request. |
Return:
Type | Description |
---|---|
SimpleRestRequest object | This method returns a SimpleRestRequest object initiated by the query transmitted; otherwise, it returns an empty SimpleRestRequest object. |
Example:
Creating a SimpleRestRequest object
/* Create a 'Telegram' request in the REST Requests (sys_rest_requests) table
and the 'Send Message' method in the REST Request Methods (sys_rest_request_method) table related with the 'Telegram' request.
Also create the 'chat_id' and 'text' Rest Request Method Param (sys_rest_request_method_param) related with the 'Send Message' method
*/
const request = sws.restRequestV1('Telegram', 'Send Message');
request.setStringParameter('chat_id', '123456789');
request.setStringParameter('text', 'telegram');
const response = request.execute();
// OR
const request = sws.restRequestV1();
request.setRequestUrl('https://api.telegram.org/bot1860462740:AAHyP6BMH2Mh-cXezrTVu2sJUoNYvimMRMQ/sendMessage');
request.setQueryParameter('chat_id', '123456789');
request.setQueryParameter('text', 'telegram');
const response = request.execute();