This server class allows operating with the REST API methods and parameters.
Tip |
---|
Change the REST_message_record text from the examples below to the record name of your REST message. |
Initialises an empty SimpleRestRequestApi object. When using such object, specify the method and the endpoint manually.
Creates an instance of the SimpleRestRequestApi object using information from the REST message record. You need to have a REST record before using this constructor.
Name | Type | Mandatory | Default Value |
---|
requestName | String | Y | N |
methodName | String | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | SimpleRestRequestApi |
---|
|
varconst sm = new sn_wssws.SimpleRestRequestV1restRequestV1('REST_message_record', 'get') |
Sends the REST message.
Return:
Type | Description |
---|
SimpleRestResponse | Response to the message sent by the execute() method. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | execute |
---|
|
varconst sm = sws.restRequestV1('slack_platform', 'send_message');
sm.setRequestBody(json_m);
sm.execute(); |
Sets the username for web-service auth if the basic auth type was chosen.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
userName | String | Y | N |
userPass | String | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | setBasicAuth |
---|
|
varconst sm = new sn_wssws.SimpleRestRequestV1restRequestV1('REST_message_record', 'get');
sm.setBasicAuth('username', 'password'); |
Sets the request URL.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
requestUrl | String | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | setRequestUrl |
---|
|
varconst sm = new sn_wssws.SimpleRestRequestV1restRequestV1('REST_message_record', 'get');
sm.setRequestUrl(“url”); |
Sets the requesting method (GET, POST, PURGE, etc). Accepts the requesting method name.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
methodName | String | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | setRequestMethod |
---|
|
varconst sm = new sn_wssws.SimpleRestRequestV1restRequestV1('REST_message_record', 'get');
sm.setRequestMethod('get'); |
Sets the response timeout until the request is out of time.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
timeout | Integer | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | setRequestTimeout |
---|
|
varconst sm = new sn_wssws.SimpleRestRequestV1restRequestV1('REST_message_record', 'get');
sm.setRequestTimeout('60000'); |
Adds a parameter into the end of the request URL generated as "name=value",
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
name | String | Y | N |
value | String | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | setQueryParameter |
---|
|
varconst sm = new sn_wssws.SimpleRestRequestV1restRequestV1('REST_message_record', 'get');
sm.setQueryParameter('sysparm_query', 'active=true^ORDERBYDESCcategory'); |
Sets the request body when used PUT or POST methods.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
body | String | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | setRequestBody |
---|
|
varconst sm = new sn_wssws.SimpleRestRequestV1restRequestV1('REST_message_record', 'get');
varconst body = '<Message body content>';
sm.setRequestBody(body); |
Sets the request variable with the name specified from the record to the value specified.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
name | String | Y | N |
value | String | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | setStringParameter |
---|
|
varconst sm = new sws.RestRequest('<REST_request_record>','get');
sm.setStringParameter('s','NOW'); |
Sets the HTTP header in the request for the value specified.
Parameter(s):
Name | Type | Mandatory | Default Value |
---|
name | String | Y | N |
value | String | Y | N |
Return:
Type | Description |
---|
Void | This method does not return a value. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | setRequestHeader |
---|
|
varconst sm = new sn_wssws.SimpleRestRequestV1restRequestV1('REST_message_record', 'get');
sm.setRequestHeader('Accept', 'Application/json'); |
Displays the request URL with parameters.
Return:
Type | Description |
---|
String | The request URl. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getRequestUrl |
---|
|
varconst sm = new sn_wssws.SimpleRestRequestV1restRequestV1('REST_message_record', 'get');
varconst url = sm.getRequestUrl(); |
Returns the request body.
Return:
Type | Description |
---|
String | The request body. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getRequestBody |
---|
|
varconst sm = new sn_wssws.SimpleRestRequestV1restRequestV1('REST_message_record', 'get');
varconst body = sm.getRequestBody(); |
Returns all the requested headers.
Return:
Type | Description |
---|
Array | The requested headers. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getRequestHeaders |
---|
|
varconst sm = new sn_wssws.SimpleRestRequestV1restRequestV1('REST_message_record', 'get');
varconst headers = sm.getRequestHeaders(); |
Returns the requesting method
Return:
Type | Description |
---|
String | The method name. |
Example:
Code Block |
---|
language | js |
---|
theme | Eclipse |
---|
title | getRequestMethod |
---|
|
varconst sm = new sn_wssws.SimpleRestRequestV1restRequestV1('REST_message_record', 'get');
varconst method = sm.getRequestMethod(); |