Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
MStuparu-Ionica
Contributor
Contributor

Recursively call API

Hello,

We are working to create ETL processes with Talend Studio.

One issue we have, in fact a problem which we don't how to approach best:

1) we do an API call.. the response will contain a list of users with different attributes: name, username, department, manager, etc...

2) manager is in fact an array that contains another API. Calling this API we can return the manager attributes: name, email address, etc...

Now the question: how can we recursively call an API with Talend Studio ? So for each user object from the JSON file, how can we call the API for the manager ?

Can be also seen as a general question. Let's say API "api_call/users" will return me all the users (ID, name, email), but if I want to find accesses and permissions they have, I need to call another API: "api_call/users/<ID>", where ID is a variable, an unique identifier of the users.

How can we do with Talend Studio ?

Thank you,

Mihai

Labels (3)
3 Replies
gjeremy1617088143

you can use tFlowtoIterate component after the first call, so it will iterate on each user and stock all the values in globalVar, so you can call your Api for the value of the manager you get from the first call and then rearange the data to combine user and manager with the globalVar wich are stored by the tFlowToIterate component (you have to do all this thing in the same iteration), you can adopt the same method to get accesses.

 

eg:

first api call return flow --> main link --> tFlowToIterate--> iterate link --> api call with value stored by the tFlowToIterate component --> main --> tMap with output schema wich contain user and manager fields (user fields will be filled by tFlowToIterate globalVar).

Send me love and kudos

MStuparu-Ionica
Contributor
Contributor
Author

hello @guenneguez jeremy​ :

 

Here it is the way my board looks now:

 

0695b00000OCTe0AAH.pngThe problem I have is that the manager field is not available for all users.

So, I call first API, I get 3 column: username, first_name, manager. Manager can be empty or not. If it is not empty, it will be an array, like {value: <API>, id: <id>}. So in my first tExtractJSONField I extract username, first_name and manager.value.

If it is empty and I try to call the API (basically I call nothing), I'll receive an error. So I added a tJava component that will call the second API only if manager attribute is not null.

But, doing so, I lose the list, I will split the users in two: with managers and without. Plus, the ones without managers are not shown the way they should.

 

With these new details, do you have any advise for me ?

 

 

MStuparu-Ionica
Contributor
Contributor
Author

Running the board the way I showed above, return this. So I don't have a single list, but for each call different reply.

For users without managers (null), it forget the first_name and the other values

 

0695b00000OCTriAAH.png