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

  1. Create necessary REST requests here: REST Client → REST Requests.
  2. Schedule their regular execution with any preferred tool.

User case

We had a user case the point of which was in implementing of the integration with one of the popular messengers. This can be done easily via the REST API.

What should be done in common integration case:

  1. Create a REST request in the appropriate section.
  2. Add related request request header(s).
  3. Add related request methods.
  4. Specify related request method parameters if necessary.
  5. Specify authentication profiles if the integration case requires this.

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

This code example implements simple operation with API of one of the popular messengers:

SimpleRestRequest
/* Create the 'Telegram' request in REST Requests (sys_rest_requests) table
and the '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 '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()

Creating REST Requests


To create a REST request, please complete the steps below:

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

REST Requests form fields

FieldDescription
NameRequest name.
Description(Optional) Request description.
REST URLURL for the REST request provided by the API supplier.
Access type

Specify access level type for this REST request:

  • All application scopes
  • This application scope only.
Auth type

Type of authentication used in this request. Available choice options:

  • No authentication
  • Basic.
Basic auth profileChoose the profile to use for authorization in your request. Authorization profiles can be created in the appropriate section described below.

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

Example

REST Request Headers


This section is used when you need to send some information in the header of your request. Here, you can create a request header and bind it to some specified request.

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

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

Request headers form fields

FieldDescription
NameThe header name.
ValueThe header value.
REST request

Choose the REST request that is the parent for this header.

After selecting the request, this header will be displayed in the Related Lists area of this request.

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

Example

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 for returning the weather in your city.

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

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

Request method form fields

FieldDescription
NameRequest method name.
ContentRequest content.
REST URLURL for the REST request provided by the API supplier.
Auth type

Type of authentication used in this request. Available choice options:

  • No authentication
  • Basic
  • Inherit from a parent.
Request type

Specify the request type. Available choice options:

  • GET
  • POST
  • PUT
  • PATCH
  • DELETE.
REST request

Choose the REST request that is the parent for this method.

After selecting the request, this method will be displayed in the Related Lists area of this request.

Basic auth profileChoose the profile to use for authorization in your request. Authorization profiles can be created in the appropriate section described below.

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

Example

REST Request Method Params


Specify the parameters for your customized REST request method. In the example above, about the Slack integration, you're gonna need to send some parameters to get a response, like get_id, by_email, and so on.

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

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

REST Request Method Parameters form fields

FieldDescription
NameThe parameter name (for example, city_id).
ValueThe parameter value (for example, 3).
OrderSpecify the parameter position in the request in the ascending order.
REST request method

Choose the REST request method that is the parent for this parameter.

After selecting the method, this method parameter will be displayed in the Related Lists area of this method.

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

Basic Auth Profiles


If your request requires authentication during processing, then the appropriate authentication data must be provided in a timely manner. You may need this functionality is you chose 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, please complete the steps below:

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

Basic auth profiles form fields

TableDescription
NameProfile name
UsernameThe username used for authentication.
PasswordThe password used for authentication.

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

  • No labels