Applies to version: 2020.1.x; author: Franciszek Sakławski
One of the functionalities significantly extending the potential of WEBCON BPS is the possibility of using the REST API interface. This article describes how to configure a data source based on information returned by the external services that provide their API.
An example of using a REST data source can be a “Contractors” data source – connecting the source from an external system can keep the data up-to-date. Another example is the use of API provided by WEBCON BPS to display a data table based on a report from the Portal. The use of REST data sources may cause a break in the operation of the service prevents the use of the form. Also, long interface response time will have a direct impact on the quality of using the form.
The form below presents the final effect. After selecting the “Country”, the field will be automatically filled in.
Fig. 1. The form
First, you must configure the connection to the server – in the “Connections” tab, select the “REST Web Service” option. We use the free API that stores information about countries around the world. There are several types of authentication:
In the last field, enter the base service instance URL.
Fig. 2. Creating the REST Web Service connection
The next step is to create the REST Web Service data source – in the configuration, select the connection and the suffix URL (it will be added to the base service instance URL). The suffix can be parametrized if the API requires it (or allows it). Next, select the HTTP method (GET, POST, PUT, PATCH or DELETE). In this case, we use the GET method.
In the “Custom headers” tab, you can add additional header parameters according to the requirements included in the documentation of the selected API (in this case – host and API key).
In the “Filter mode” tab, you have two options – Using BPS and Using Web Service. Filtering on the BPS side will cause that the entire data collection will be downloaded first, and then the searched value will be found (e.g. contractor with a given NIP). Filtering can also be performed on the side of Web Service, but it requires the appropriate prepared service (e.g. the service must take additional parameters).
Fig. 3. The REST Web Service data source configuration
In the second tab, you can configure the response message handling. After selecting the “Load” button, the data structure returned by the service appears on the tab. In the “Result” column check the collection based on which the data table will be created.
Fig. 4. The response structure loaded
To load the structure, you must invoke the service. When it is not possible, click the “Load from sample” button – a new window will appear on the screen. Enter the ready response scheme (e.g. scheme based on the documentation). After pasting the response, WEBCON BPS Studio will map the list of fields that are returned in a given resource.
Fig.5. Copying the response content
The tab was filled out according to the loaded scheme:
Fig. 6. The completed Response tab
Next in the example process, configure the “Data source” field.
Fig. 7. Form field using the created source
Values from the field are inserted into the form fields that store information about the city’s capital, area, and population.
Fig. 8. Transferring data from the form field
The REST Web Service data sources are used to get data from the external systems. Standard WEBCON BPS functionalities allow for their configuration and use without the need to know programming languages, which facilitates the creation of new applications.