Collating Results from Multiple REST Calls

Four Stars

Collating Results from Multiple REST Calls

In my use case, I have more than one REST endpoint that I am querying for data.

 

REST Endpoint #1

StockAvailable - integer

 

REST Endpoint #2

UnitsSold - integer

GrossRevenue - decimal

 

I'd like to collate these two results into a single row of data:  StockAvailable, UnitsSold, GrossRevenue.


I've tried tUnite, but - even if I put all 3 columns on both inputs in the metadata - I still end up with a 2-row result for each query :

row1: StockAvailable, ___ , ____

row2: ___, UnitsSold, GrossRevenue

 

I've read a few posts indicating that it's just not possible to collate these results. But I wanted to ask here. Is there a way of getting this call down to a single row of collated output?


Accepted Solutions
Employee

Re: Collating Results from Multiple REST Calls

Hi,

 

    A quick way of doing is as shown below. As a first step, store the data to a Hash output component (tHashOutput) for each REST API call output (You can even use temporary files if you prefer that way). But before writing to this component, add a tMap where you need to add an additional column called sequence to capturing a running integer value.

 

So the flow each output will be,

 

REST Output -> tMap (to add sequence) -> tHashOutput

 

Now, add a On SubJob OK and read both data using two tHashInput Components and join them to a tMap. So one flow will be main and other will be lookup. Since you have same sequence number in both flow, you can use it as key to join these columns (use inner join in your case). Now, you will get the data in single line and you can ignore the dummy sequence column after the join process.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)


All Replies
Employee

Re: Collating Results from Multiple REST Calls

Hi,

 

    A quick way of doing is as shown below. As a first step, store the data to a Hash output component (tHashOutput) for each REST API call output (You can even use temporary files if you prefer that way). But before writing to this component, add a tMap where you need to add an additional column called sequence to capturing a running integer value.

 

So the flow each output will be,

 

REST Output -> tMap (to add sequence) -> tHashOutput

 

Now, add a On SubJob OK and read both data using two tHashInput Components and join them to a tMap. So one flow will be main and other will be lookup. Since you have same sequence number in both flow, you can use it as key to join these columns (use inner join in your case). Now, you will get the data in single line and you can ignore the dummy sequence column after the join process.

 

Warm Regards,
Nikhil Thampi

Please appreciate our Talend community members by giving Kudos for sharing their time for your query. If your query is answered, please mark the topic as resolved :-)

Four Stars

Re: Collating Results from Multiple REST Calls

Thank you.

2019 GARNER MAGIC QUADRANT FOR DATA INTEGRATION TOOL

Talend named a Leader.

Get your copy

OPEN STUDIO FOR DATA INTEGRATION

Kickstart your first data integration and ETL projects.

Download now

What’s New for Talend Summer ’19

Watch the recorded webinar!

Watch Now

An API-First Approach to Modernizing Applications

Learn how to use an API-First Approach to Modernize your Applications

Watch Now

Talend API Designer – Technical Overview

Take a look at this technical overview video of Talend API Designer

Watch Now

Getting Started with APIs

Find out how to get started with APIs

Read