Versions Compared
Key
- This line was added.
- This line was removed.
- Formatting was changed.
This server class
Tip |
---|
Change the REST_message_record text from the examples below to the record name of your REST message. |
execute()
Sends the REST message.
Return:
Type | Description |
---|---|
SimpleRestResponse | Response to the message sent by the execute() method. |
Example:
Code Block | ||||||
---|---|---|---|---|---|---|
| ||||||
var sm = new sn_ws.SimpleRestRequestApi(“REST_message_record”, “get”); var response = sm.execute(); |
setBasicAuth(userName, userPass)
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 | ||||||
---|---|---|---|---|---|---|
| ||||||
var sm = new sn_ws.SimpleRestRequestApi(“REST_message_record”, “get”); sm.setBasicAuth(“username”, “password”); |
setRequestUrl(requestUrl)
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 | ||||||
---|---|---|---|---|---|---|
| ||||||
var sm = new sn_ws.SimpleRestRequestApi(“REST_message_record”, “get”); sm.setRequestUrl(“url”); |
setRequestMethod(methodName)
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 | ||||||
---|---|---|---|---|---|---|
| ||||||
var sm = new sn_ws . SimpleRestRequestApi(“REST_message_record”, “get”); sm.setRequestMethod(“get”); |
setRequestTimeout(timeout)
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 | ||||||
---|---|---|---|---|---|---|
| ||||||
var sm = new sn_ws . SimpleRestRequestApi(“REST_message_record”, “get”); sm.setRequestTimeout(“60000”); |
setQueryParameter(name, value)
Adds a parameter into the end of the URL request formed as a "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 | ||||||
---|---|---|---|---|---|---|
| ||||||
var sm = new sn_ws . SimpleRestRequestApi(“REST_message_record”, “get”); sm.setQueryParameter(“sysparm_query”, “active=true^ORDERBYDESCcategory”); |
setRequestBody(body)
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 | ||||||
---|---|---|---|---|---|---|
| ||||||
var sm = new sn_ws . SimpleRestRequestApi(“REST_message_record”, “get”);
var body = “<Message body content>”;
sm.setRequestBody(body); |
setStringParameter(name, value)
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 | ||||||
---|---|---|---|---|---|---|
| ||||||
var sm = new sws.RestRequest("<REST_request_record>","get");
sm.setStringParameter("s","NOW"); |
setRequestHeader(name, value)
Method descriptionSets 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 | ||||||
---|---|---|---|---|---|---|
| ||||||
var sm = new sn_ws . SimpleRestRequestApi(“REST_message_record”, “get”);
sm.setRequestHeader(“Accept”, “Application/json”); |
getRequestUrl()
Method description
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
Return:
Type | Description |
---|---|
Example:
Code Block |
---|
Method description
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
Return:
Type | Description |
---|---|
Example:
Code Block |
---|
Method description
Parameter(s):
Name | Type | Mandatory | Default Value |
---|---|---|---|
Return:
Type | Description |
---|---|
Example:
Code Block |
---|
Table of Contents | ||||
---|---|---|---|---|
|