Phase 2 — Enrich Data
Time to complete: ~15 minutes
Overview: In this phase, you’ll extend the workflow created in Phase 1 and enrich its output with stock levels fetched from the Demo Inventory API. The result will be a workflow that combines product and inventory data into one output.
A view of the completed Phase 2 workflow.
Steps
-
In this step, you will use Martini Designer's built-in HTTP Client to consume the Get SKU operation of the Demo Inventory API and export it as a service. The process is the same as Step 3 from Phase 1. The same process is repeated here with the variables required for the Demo Inventory API. To consume the API in Martini's HTTP Client:
- Open the HTTP Client by clicking the HTTP icon in the left-hand navigation bar.
- Start a new request by clicking the + button in the HTTP Client toolbar.
- Enter the following values in the HTTP request editor:
- Method: GET
- URL:
https://demo-api.apiexplorer.io/api/lonti_demo_api_inventory/1.0/sku/product_code/{productCode}
- Under the Authentication tab enter the following values:
- Authentication: OAuth 2.0
- Access Token:
<paste the token from Phase1, Step 1>
- Under the Parameters tab enter the following values:
- productCode:
SKU001
(note that the value is case sentitive)
- productCode:
- Click Send to execute the request.
- Expected output:
- Status:
200
- Body:
<a JSON object containing a SKU>
- Status:
The object below is a representative element of a SKU returned:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
{ "result": "OK", "message": "OK", "warnings": [], "sku": { "sku_id": 1, "sku_name": "Chisel Wood 6mm", "product_code": "SKU001", "barcode": 12345678, "stock_in": 383, "stock_out": 192, "stock_on_hand": 191, "stock_reserved": 0, "stock_available": 191, "modified_date": "2025-09-08T00:00:04+0000", "created_date": "2025-09-08T00:00:04+0000" } }
-
In this step, you will save the HTTP Client request from Step 1 as a reusable service. Services can be included as a step within a workflow or can be configured as a handler for an API operation. To save the HTTP Client request and export it as a service:
- With the HTTP Client request tab still active, click Save in the main toolbar.
- Enter any name for the request (or accept the default) and click Save.
- The saved request will appear under the User Requests in the HTTP Client panel. Right-click it and select
Export → Service
. - Use the Browse button to select the Package
my-first-project
. - Name the service
GetInventorySkuByProductCode
, click Next, accept the defaults, then click Finish.
-
In this step, you will create a new output model for the workflow that includes additional properties for the stock levels that will be returned by the Demo Inventory API. To create a new output model for the workflow:
- Click on the Input/Output icon in the workflow editor toolbar for the
MyFirstWorkflow
workflow. - The mapper displays a single column for the Inputs to the Workflow and a single column for the Outputs from the Workflow. We will duplicate the existing
skuArray
data model and add properties to the new model. To do that right-click theskuArray
model and select Copy then right-click anywhere thereunder and select Paste. The duplicated model will be calledskuArray1
, rename it by right-clicking it, selecting Rename, and enteringskuArrayWithStockAvailable
. - Add the following property to the new data model
skuArrayWithStockAvailable
by selecting it and clicking the+
icon in the Output toolbar. Select the Type = Integer and name the propertystockAvailable
.
- Click on the Input/Output icon in the workflow editor toolbar for the
-
In this step, you will start building out the rest of our workflow. As the output from the
GetAllEcommerceSku
service is an array we will add a Repeat node to the workflow to iterate over its output. To iterate over the results of a previous node:- Click the
+
icon in the toolbar of the workflow editor for theMyFirstWorkflow
workflow. - Drag the Repeat node onto the workflow editor canvas and drop it next to the
Invoke GetAllEcommerceSku
node. Then click thex
icon to close the modal. - If placed correctly, it should draw a line connecting the two nodes automatically. If not then simply connect the two nodes by dragging the output arrow of the
Invoke GetAllEcommerceSku
node to the input arrow of the Repeat node. - Click the expand icon on the Repeat node to set the Input and Output Arrays as follows:
Input Array:
skuArray
Output Array:skuArrayWithStockAvailable
Then click thex
icon to close the modal.
- Click the
-
In this step, you will map the output from the
GetAllEcommerceSku
service to the new data modelskuArrayWithStockAvailable
. To map the output from the previous Repeat node:- Click the
+
icon in the toolbar of the workflow editor. - Drag the Map node onto the workflow editor canvas and drop it next to the Repeat node. Then click the
x
icon to close the modal. - Connect the two nodes by dragging the output arrow labelled
each
of the Repeat node to the input arrow of the Map node. - Click the expand icon on the Map node to open the input/output mapper.
- Drag the input
skuArray
to the outputskuArrayWithStockAvailable
. A line will be drawn on the connecting the two data models. All of the values from the input will now be mapped to the output with the corresponding property. - Click the
x
icon to close the mapper.
- Click the
-
In this step, you will include the
GetInventorySkuByProductCode
service that you created in Step 2 into your workflow. To include the service:- Locate the
GetInventorySkuByProductCode
service in your packagemy-first-project
, drag it onto the workflow editor indicated by the tab labeledMyFirstWorkflow
, and drop it next to the Map node. - If placed correctly, it should draw a line connecting the two nodes automatically. If not then simply connect the two nodes by dragging the output arrow of the Map node to the input arrow of the node labelled
Invoke GetInventorySkuByProductCode
.
- Locate the
-
In this step, you will configure the inputs and outputs of the
Invoke GetInventorySkuByProductCode
service. To configure the inputs and outputs of the service:- Expand the
skuArray
model in the Input panel then drag its propertyproductCode
to the inputproduct_code
. This will take the value of theproductCode
returned by theGetAllEcommerceSku
service and map it to the input variableproduct_code
of theGetInventorySkuByProductCode
service. - Expand the
GetInventorySkuByProductCodeOutput
data model and thesku
object thereunder in Output panel. - Expand the
skuArrayWithStockAvailable
data model in the Output panel. - Drag the property
stock_available
tostockAvailable
. This will take the valuestock_available
returned by theGetInventorySkuByProductCode
service and map it to your enrichedskuArrayWithStockAvailable
data model.
- Expand the
-
Run your workflow to verify its output. To run your workflow:
- Click the Run button in the workflow editor toolbar. Accept the defaults and click Run.
- Expected output in the Console:
- Logs tab:
<Output available, click the Output tab to view it>
- Output tab: Expand the tree
skuArrayWithStockAvailable
→[0]
…[n]
- Logs tab:
The object below is a representative element of the list/array of SKUs returned:
1 2 3 4 5 6 7 8 9 10 11 12
{ "skuId": 1, "name": "Chisel Wood 6mm", "productCode": "SKU001", "productVariant1": "Wood", "productVariant2": "6mm", "price": 13, "createdDate": "2025-08-12T02:30:21+0000", "modifiedDate": "2025-08-12T02:30:21+0000", "itemId": 1, "stockAvailable": 191 }
What’s next: In Phase 3 you’ll learn how to store data in a database.