Document toolboxDocument toolbox

Support center for flex.bi version 3.2

REST API (non-HansaWorld app)

To use REST API as a data source you have to do the following steps:

Create a new source application in the flex.bi source application tab.

 

Make sure you select REST API as your data source when creating a new source application

If you have created already another similar REST API data source then you can export its definition and paste it in Import definition to create new REST API source application with the same parameters.

REST API source parameters

For the following fields provide the information required:

Source data URL

For the source data URL enter the REST API URL which returns data and all the parameters that are needed for your data.

Pagination parameters

Specify if you the REST API request can return all the data with a single request, otherwise you must specify the page parameter or offset and limit parameter.

Use Page parameter if you want to return pages of data. You have to specify the name of the page parameter REST API should use to return paginated data.

If you want to return a certain amount of data use Offset and limit. The limit tells REST API how many records to return and offset tells REST API from which record it should start getting the data. If offset is est to 20 and the limit to 30, REST API will return records from 20-50

Authentication parameters

Select the type of authentication you are using and enter all the values that are required for it.

 

Content parameters

Select the kind of data your REST API request will return. Your choices are JSON, XML or CSV.

You can also add custom JavaScript code if you chose JSON as your content parameter.

Custom JavaScript code

You can use custom JavaScript code to modify received JSON, XML or CSV data before importing into flex.bi. Click Add custom JavaScript code to show code editor.

You can use doc variable to access received data object properties and modify or add additional properties. If necessary you can define additional JavaScript functions that you need to use in your code.

Here is example of JavaScript code which will change title property to capitalized version (first capital letter and then lowercase letters):

 

function capitalize(s) {
  return s.charAt(0).toUpperCase() + s.slice(1).toLowerCase();
}
doc.title = capitalize(doc.title);

 

If you would like to skip some data rows and do not import them in flex.bi then use return false; in these cases. Here is example which will skip data rows which do not have title property:

 

if (!doc.title) return false;

 

You can also create new properties for doc object when you need to construct flex.bi dimension level names or calculate additional measures. Here is example how to create full_name property:

 

doc.full_name = doc.first_name + " " + doc.last_name;

 

Import parameters

Select the frequency of the data import. An automatic import will be started every time the specified amount of time passes.

Source column mapping

Once you have finished setting your parameters you will have to conduct the Source column mapping.

Mapping the data to columns is similar to importing a .csv/.xls file. The differences here are that you need to name your own cube and dimensions, because they need to be created if your data does not fit any of the already existing cubes.

When you are finished mapping your data press the Start Import button.

If your import finishes successfully you can see the results in the Analyze tab in the cube you imported your data to.