Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

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.

...

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.

...

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.

...