Low-Code REST Integration with Rollbase

Low-Code REST Integration with Rollbase

April 10, 2017 0 Comments
Low-Code REST Integration with Rollbase_870x220

Connect to any REST service without writing code and develop your apps faster with the new REST integration in Progress Rollbase.

In today’s world, most of the service providers provide APIs to access their services through RESTful web services. RESTful web services are lightweight, highly scalable and very commonly used to create APIs for web based applications. In this blog, you will learn how to connect such external REST services to Rollbase.

Low-Code REST integration

We've added a new trigger type called REST service to enable REST integration with Rollbase. This feature enables access to REST end points without coding. Using a mapping tool, a user can associate fields from Rollbase objects to REST service requests (request parameter and request body) and map response fields to fields of Rollbase objects.The tool will auto-generate JavaScript code so that you can make an integration in a few minutes. You can connect to any JSON REST service by using this feature. It supports the following HTTP methods:

  • GET – To get REST data to Rollbase fields
  • POST – Create new record in REST service by using Rollbase fields
  • PUT – Update record in REST service by using Rollbase fields

This feature also supports Basic Authentication.

How to Integrate

Only administrators or equal admin privileged user can create a REST service type trigger.

Follow the below steps to create a new REST service trigger that integrates a REST endpoint to a Rollbase set of objects.

Create New Trigger

From the object definition page, click “New Trigger button” and select type as “REST service” from the next screen.

Configure REST Parameter

Name your trigger and trigger timing option, and then select Rest Service Configuration section (see screenshot below).

Enter your REST endpoint static URL Path, select your HTTP method. By default, Authorization is selected as “No Auth,” when you select Authorization as “Basic Auth” you need to provide details of Username and Password. Once you complete these details click on the Configure button which leads you to specify different metadata based on the HTTP method you selected.

For GET you can configure HTTP headers, URL Path & URL Parameters. For POST & PUT you can configure HTTP headers, URL Path & Request data as body JSON. 

All these can be configured to either use data from a Rollbase record or to be constant values.

From mapper screen, you can create mapping fields or constant fields. 

  • Mapping Fields: When a user adds a mapping field, they should be able to map a Rollbase field to a newly added mapping field by dragging a connector. These mapping fields values will be resolved to the record value on which the trigger is executing. See in the below screenshot, which adds CityId as a URL parameter with key name as “id” and a value of CityId token. All mapping pairs key will default to the field name and the value of the token. The user can’t edit the value but can edit the key. This is to prevent any accidental mistake a user would make by editing the token. The same is applicable for the Header and URL Builder tab.
  • Constant pair: Constant pair values remain the same irrespective of which record the trigger is executing on. See in the below screenshot where APPID is configured as a constant pair which is common across all trigger. The user can edit both key and value if added as constant pairs.

After adding mapping pairs, if one would like to edit/delete them that can be done by hovering on rows and clicking the edit and delete button. The user can also sort the order of mappings by drag and drop.

Configure Response

After you configure all required configurations, click on the Response tab or click “Configure Response” button. This will show the response tab, from which you can make a test connection to your REST endpoint and get a sample response to build a Response tree. Alternatively, you can build the response tree by copying the JSON response from the service into the text input. The response tree is required only if REST field values must be updated on the Rollbase side, otherwise you can simply ignore this Response Tree mapping (say for POST and PUT user can simply ignore any update to Rollbase field since most of the time POST and PUT will be an update at REST side). After the tree is built the user can add/delete/edit more nodes to Response right tree by using toolbar buttons.

From Response Tree, the user can map fields from REST service fields to Rollbase fields. If the user maps REST field to Rollbase Base object fields, then we update the Rollbase field value. If the user maps REST fields to Rollbase Related object fields, then we give the user three options:

  1. Add sub-objects as new Record – Add new related item and attach to parent object on which trigger is executed
  2. Update an existing Record – Update existing related record based on the condition provided by user on mapper screen. When a user selects this option, they will be prompted by another dialog from which they should map the fields to uniquely identify an existing record. If there are multiple mappings, consider as AND conditions.
  3. Update if existing, else Add as new – Update the existing related record if condition matches, else add new record and attach to parent object. When a user selects this option, they will be prompted by another dialog from which they should map the fields to uniquely identify an existing record. If there are multiple mappings, consider as AND conditions.

Example

Say the user would like to get a weather report for next 7 days from a REST service for a different Progress office. In Rollbase, create a "Building" object to denote a different Progress office across the country, create another object called "Day Wise Weather" and add a relationship with "Building" object.

Create a new "REST Serive" trigger, provide the URL and add a Query parameter to pass Progress office CityId and API key as mentioned above in the Request mapping section.

The next step will be building a sample Response tree by invoking a REST endpoint as mentioned above. Now you can map fields from Response Tree to Rollbase related fields. You will be asked the three options mentioned above. Then choose Add as new record.

Once Response mapping is done, click on the “OK” button to generate trigger code. 

At this stage, without any coding you have a fully working call to an external REST service.

We recognize there are times when you would want to customize the processing of the service request or of the response. You can do that very simply with a little bit of JS code. We will go over how this works in the next section.

There will be two sections of code that get auto generated. Non-editable auto generated code and customizable callback methods code. Non-editable JavaScript code gets generated every time you change the mappings, whereas customizable code will not be regenerated to preserve all the changes the user has done.

How to Customize Trigger Code for Data Type for Other Purposes

Rollbase auto generates code for your mappings with two sections of JavaScript code. The first section is customizable code and the second section is non-editable code. The customizable code section includes callback methods for data conversion before updating REST and Rollbase fields, and callback methods for processing Request to REST and Response from REST. The idea for customization code block is a user who has knowledge on JavaScript can play with these callback methods to control the data sent to REST and update Rollbase fields. This helps the user have full control of the execution of the trigger and overcome, if there are any, limitations that can’t be done through mapping (but we tried our best to cover most of the user’s use cases by default using our mapping tool). As a Low-Code platform, Rollbase provides more flexibility to the user to add more logic along with the default one that can be achieved by using custom code section.

A Low-Code Connection to REST Services

Rollbase enables users to connect any REST service without writing much code. The user doesn’t need to have any programming skill to connect to the REST service, and they can use a simple mapping tool to connect Rollbase and REST fields. This helps the user to build complex business application very quickly. Refer to the Rollbase documentation for more details.

New to Rollbase and want to try it out? You can sign up for a free trial here.

Vimalkumar-Selvaraj

Vimalkumar Selvaraj

Vimalkumar is a Senior Software Engineer at Progress. He's worked intensively on different UI technologies such as Angular JS, JQuery, Bootstrap, Kendo UI, Ext.JS , HTML5, CSS3 and Javascript for more than 4.5 years, and has 7 years of overall experience in software development. He previously worked on various Progress Cloud product UI development (Data Direct Cloud and Easyl) and is currently working on Rollbase UI development.

Read next OData FAQs: Why Should REST API Developers Use OData?
Comments
Comments are disabled in preview mode.