Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Iterate over nested REST API Queries

I have a system that I am trying to interact with that provides a set of nested entities through JSON. I have my top level REST queries working correctly (tREST component, feeding into a tExtractJSONFields - the fields are showing up correctly.)
For the next part of my process, I need to extract a single field from the tExtractJSONFields result, and send that query back to my parent system ( https://api.system.com/getSubEntities?id=JSONID), so that I can iterate over those results. This process should continue down until I no longer receive sub entities. What is the best way to feed that result back into a REST query and iterate down?
Thank you!
Labels (4)
1 Reply
Anonymous
Not applicable
Author

Hi
Use a tLoop to make a loop exectuion for the processing until it return no sub-entities, the job design looks like:
tLoop--iterate--tRest--main--tExtractJSONFields--main--tJavaRow
Define a context variable, boolean type, let's call it condition and set its default value as true, and another context variable, name it as url and set a default value for it.
on tLoop, set the Condition field as: context.condition
on tRest, set the URL field as: context.url
on tJavaRow:
change the url based on the return field, for example:
context.url="https://api.system.com/getSubEntities?id="+input_row.fieldName
check the return field and determine to stop the loop or not, for example:
if(input_row.fieldName==null){ //or other condition according to your real case.
context.condition=false;
}else{
context.condition=true;
}
Shong