5. REST API Endpoint (POST)

No items found.


Installed connectors Microsoft SQL database, JS Mapper, REST API (see tutorial 1.)


In the following tutorial, we will create a new integration task that loads data from SQL database, transforms them using Javascript and sends them to a new Xeelo DX endpoint.

1. Login

Log in to Xeelo DX and click the Tutorials tile in the Companies section.

2. Creating an integration task

Create a new integration task using the Add button. Change the job name and confirm.

3. Create a new integration step Select data from SQL

  1. Create a new Integration Task Step
  2. Rename the integration step to: Select data from SQL
  3. In the Connector section, search for SQL and choose Microsoft SQL Connector
  4. Add the following in the Output Scheme:
    • ID: integer
    • Fruit: String
    • Price: Double and check Null. This means that the value can take on empty values
    • Save the scheme as Fruits with price
  5. In the configuration section
    • Load existing SQL Connection string via blue list icon
    • Add the following SQL statement:
      SELECT [id] ,[fruit] ,[price] FROM [dbo].[dx_demo_fruits]
    • Save the configuration and integration step

4. Create a following integration step JSMapper - map data

  1. Create a following integration task by clicking on small icon button
  2. Rename integration step to: JSMapper - map data
  3. Select the JS Mapper connector
  4. Change input processing to Bulk
  5. In the Input Scheme, select Fruits with price using the blue icon at the top right
  6. In the Input Mapping, press the double arrow button right next to the Select data from SQL heading
  7. Add the following in the Output Scheme:
    • ID: integer
    • Fruit: String
    • Price: Double and check Null
    • Weight: Double and check Null
    • Save the scheme as Fruits with weight
  8. In the configuration section, add following Javascript:
    // define array with colors for enhancing data - fruit color var colors = Array('red','yellow','green','orange','brown'); // data from previous step are stored in variable inputData // using map function can be all records in array mapped to different values or enhanced about some data var output = inputData.map(function(item) { return { // follow same value into output ID:item ,Fruit: colors[Math.floor(Math.random()*colors.length)] + ' ' + item.Fruit ,Price: item.Price // enhance new value to output ,Weight: Math.floor(Math.random() * (1000 - 100) + 100 ) / 100 }; }); // send variable to output schema - must have elements with the same names (also same case) and same data types return output;

5. Creating Xeelo DX endpoint Send me a fruit

  1. We need to create an endpoint where we send the data. Use the breadcrumbs navigation to close the task and press the Endpoint tile in Tutorials
  2. Press Add
  3. In the General section:
    • Name endpoint Send me a fruit
    • Generate a slag using the button
    • Insert * into the IP filter
    • Select Type to Input
    • Save the endpoint
  4. At the top of the endpoint copy the endpoint address, eg. https://your-dx-tutorial-site.online/api/endpoint/tutorials/default-group/send-me-a-fruit

6. Create a following integration step Send data to REST endpoint task

  1. Create and rename an integration task
  2. Vytvořte a přejmenujte integační úlohu
  3. Choose the REST API connector
  4. Change Input processing to Bulk
  5. Select the existing Fruits with weight in the Input scheme
  6. In the Input Mapping section, press the double arrow right next to JS Mapper - map data heading
  7. Fill in the configuration:
    • URI: https://your-dx-tutorial-site.online/api/endpoint
    • Save as DX URL
    • Endpoint: /tutorials/default-group/send-me-a-fruit
    • Request type to POST
    • Data type to JSON
    • Data: ${input}
    • Save the configuration
  8. Save and close the integration step

7. Nastavte hromadně data snapshot

  1. Na obrazovce integrační úlohy stiskněte v pravé hodní části ikonu podmenu (3 tečky pod sebou) a zvolte hromadné editování kroků (bulk edit steps)
  2. V zobrazeném modálním okně zvolte Data snapshot - Everytime
  3. Uložte

8. Save and close the integration step

  1. To run an integration task: Switch the Runnable / Not runnable checkbox at the top of the screen to the Runable - green backlight state. You may notice that at the same time, the History / Design switch changes to the left
  2. Refresh the Xeelo DX cache using the gray recycle button at the top right of the screen, next to the profile. In this way, Xeelo
  3. Press the green Start button next to the History button. A green message will appear in the lower right corner
  4. On the left side of the screen, press the Reload task runs button
  5. Press the orange Data snapshot button on the last green integration steps and compare the outputs

9. Checking the data on the Xeelo DX endpoint

  1. Open a new browser window and load https://your-dx-tutorial-site.online/api/endpoint/tutorials/default-group/send-me-a-fruit
  2. Download the file and open it in a text editor