SimpleWebService
Use this server class to create a SimpleRestRequest object.
restRequestV1(requestName, methodName)
Use this method to create a SimpleRestRequest object and pass parameters into it.
note
If parameters are not specified in the restRequestV1() method, manually set up the SimpleRestRequest object using its methods.
The SimpleRestRequest article describes how to pass values to the requestName and methodName parameters.
Parameter(s):
Name | Type | Mandatory | Default value |
---|---|---|---|
requestName | String | N | '' |
methodName | String | N | '' |
Return:
Type | Description |
---|---|
SimpleRestRequest object | This method returns a SimpleRestRequest object initiated by the given parameters. |
Example:
restRequestV1()
/* Create a 'Telegram' request in the REST Requests (sys_rest_requests) table
and a 'Send Message' method in the REST Request Methods (sys_rest_request_method) table related to the 'Telegram' request.
Also, create 'chat_id' and 'text' Rest Request Method Param (sys_rest_request_method_param) related to 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();