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:
- Create necessary REST requests here: REST Client → REST Requests.
- 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:
- Create a REST request in the appropriate section.
- Add related request request header(s).
- Add related request methods.
- Specify related request method parameters if necessary.
- 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:
/* 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:
- Navigate to REST Client → REST Requests.
- Click New and fill in the form.
- Click Save or Save and Exit to apply changes.
REST Requests form fields
Field | Description |
---|---|
Name | Request name. |
Description | (Optional) Request description. |
REST URL | URL for the REST request provided by the API supplier. |
Access type | Specify access level type for this REST request:
|
Auth type | Type of authentication used in this request. Available choice options:
|
Basic auth profile | Choose 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:
- Navigate to REST Client → Headers.
- Click New and fill in the form.
- Click Save or Save and Exit to apply changes.
Request headers form fields
Field | Description |
---|---|
Name | The header name. |
Value | The 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:
- Navigate to REST Client → Methods.
- Click New and fill in the form.
- Click Save or Save and Exit to apply changes.
Request method form fields
Field | Description |
---|---|
Name | Request method name. |
Content | Request content. |
REST URL | URL for the REST request provided by the API supplier. |
Auth type | Type of authentication used in this request. Available choice options:
|
Request type | Specify the request type. Available choice options:
|
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 profile | Choose 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:
- Navigate to REST Client → Method Params.
- Click New and fill in the form.
- Click Save or Save and Exit to apply changes..
REST Request Method Parameters form fields
Field | Description |
---|---|
Name | The parameter name (for example, city_id). |
Value | The parameter value (for example, 3). |
Order | Specify 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:
- Navigate to REST Client → Basic Auth Profiles.
- Click New and fill in the form.
- Click Save or Save and Exit to apply changes.
Basic auth profiles form fields
Table | Description |
---|---|
Name | Profile name |
Username | The username used for authentication. |
Password | The password used for authentication. |
To get a list of available basic auth profiles, please navigate to REST Client → Basic Auth Profiles.
- No labels