Skip to main content
Version: 1.22.3

REST Client

In SimpleOne, you can use the REST client to integrate the system with third-party services using their REST API. To connect such a service with your SimpleOne instance, complete the following steps:

  1. Create necessary REST requests in REST API Client → Requests.
  2. Schedule their regular execution with any convenient tool.

Use case

You need to integrate with one of the popular messengers.

To do so, complete the following steps:

  1. Create a REST request in the appropriate section.
  2. Add related request headers.
  3. Add related request methods.
  4. Specify the parameters of the request methods, if necessary.
  5. Specify authentication profiles if the service integration requires this.
caution

To call third-party services in a REST client, use the methods of the SimpleRestRequest server-side class.

The following code example implements simple work with the API of one of the popular messengers:

SimpleRestRequest
/* Create a 'Telegram' request in the REST Requests (sys_rest_requests) table
and a 'Send Message' method in REST Request Methods (sys_rest_request_method) table related with 'Telegram' request.
Also create '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()

Create REST Requests


To create a REST request, complete the steps below:

  1. Navigate to REST API Client → Requests.
  2. Click New and fill in the form.
  3. Click Save or Save and exit to apply the changes.

REST Requests form fields

FieldMandatoryDescription
NameYSpecify a request name.
DescriptionNAdd a request description.
REST URLYSpecify the URL for the REST request provided by the API supplier. Specify the URLs only with the http or https protocols.
Access typeYSpecify an access level type for this REST request:
  • All application scopes
  • This application scope only
Auth typeYSelect the type of authentication used in this request. Available choice options:
  • No authentication
  • Basic
Basic auth profileNSelect the profile that is used for authorization in your request. Authorization profiles can be created in the Basic Auth Profiles.

To get a list of available REST requests, navigate to REST Client → Requests.

REST Request Headers


Create a request header and bind it to some specified request to send some information within the request.

To create a new REST request header, complete the steps below:

  1. Navigate to REST API Client → Headers.
  2. Click New and fill in the form.
  3. Click Save or Save and exit to apply the changes.

Request headers form fields

FieldMandatoryDescription
NameYSpecify the header name.
ValueYSpecify the header value.
REST requestYSelect the REST request that is the parent for this header.
This header is displayed in the Related Lists area of the selected request.

To get a list of available REST request headers, navigate to REST Client → Headers.

REST Request Methods


This functionality is used when you need to implement a new method within your REST request. For example, if you are using some weather service, you can implement a method to return the weather forecast for your city or location.

To create a new REST request method, complete the steps below:

  1. Navigate to REST API Client → Methods.
  2. Click New and fill in the form.
  3. Click Save or Save and exit to apply the changes.

Request method form fields

FieldMandatoryDescription
NameYSpecify a request method name.
ContentNAdd the request content.
REST URLYSpecify the URL for the REST request provided by the API supplier. Specify the URLs only with the http or https protocols.
Auth typeYSelect the type of authentication used in this request. Available options:
  • No authentication
  • Basic
  • Inherit from a parent
Request typeYSpecify the request type. Available options:
  • GET
  • POST
  • PUT
  • PATCH
  • DELETE
REST requestYSelect the REST request that is the parent for this method.
This method is displayed in the Related Lists area of the selected request.
Basic auth profileNSelect the profile that is used for authorization in your request. Authorization profiles can be created in the Basic Auth Profiles.

To get a list of available REST requests methods, navigate to REST Client → Methods.

REST Request Method Params


Specify parameters for your customized REST request method. In the Slack integration example above, you need to send some parameters to get a response, such as get_id, by_email, and others.

To create a new REST request method parameter, complete the steps below:

  1. Navigate to REST API Client → Method Parameters.
  2. Click New and fill in the form.
  3. Click Save or Save and exit to apply the changes.

REST Request Method Parameter form fields

FieldMandatoryDescription
NameYSpecify the parameter name (for example, city_id).
ValueYSpecify the parameter value (for example, 3).
OrderNSpecify the parameter position in the request in the ascending order.
REST request methodYSelect the REST request method that is the parent for this parameter.
This method parameter will be displayed in the Related Lists area of the selected method.

To get a list of available REST requests methods parameters, navigate to REST Client → Method Parameters.

Basic Auth Profiles


Provide the appropriate authentication data timely if your request requires authentication during processing. You may need this functionality if you select the Basic option in the Auth type choice list.

In SimpleOne, authentication data is kept in the pairs called "basic auth profiles". These profiles contain usernames and passwords.

To create a basic auth profile, complete the steps below:

  1. Navigate to REST API Client → Basic Auth Profiles.
  2. Click New and fill in the form.
  3. Click Save or Save and exit to apply the changes.

REST Request Method Parameter form fields

FieldMandatoryDescription
NameNSpecify the profile name.
UsernameNSpecify the username used for authentication.
PasswordNSpecify the password used for authentication.

To get a list of available basic auth profiles, navigate to REST Client → Basic Auth Profiles.