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

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Davew1
Contributor II
Contributor II

Best way to pass an input parameter for a tRest Comonent to the tRest Output?

The scenario I have is to perform an action on a Rest API that requires a single ID to be passed in the URL. the response then returns a single Row of data with a JSON structure for a single record which i can happily parse with textractJSONFields. However, the record ID (the one I passed into the tRest Component) is not included in the JSON response. The ID I'm inputting to the tRest component is a data flow (i.e. 400 IDs). I need to join the responses with the original ID. Assuming the rows in the output are returned in the as the same order as the input I can store the inputs with a row number:ID pairs and calculate the row numbers on the output and join back to the ID with a lookup (i.e. joining based on row number in the flow). Is there a better approach to solve this problem?

 

Another idea I can think of is to use a tLoop and pass the ID in one row at a time via a Global variable and then use a tJavaRow to join back my ID form the Global Variable after I've parsed the JSON.

 

What would be the best approach?

Labels (4)
1 Reply
Anonymous
Not applicable

Hi
If the ID comes from a data flow, you can store it to a global variable for used later. eg:
your input data--main--tJavaRow
|onsubjobok
tRest-->tMap--->

on tJavaRow:
globalMap.put("key",input_row.IDColumnName);

on other components in next subjob, you can get the value of ID' column with expression:
(String)globalMap,get("key")

//Assuming the data type of ID column is string.

Hope it helps!

Regards
Shong