Looping over API/JSON

Hello Knime Community,

I receive Data via a Get Request. Due to restrictions not all Data can be retrieved, so beside Data the Request also delievers an URL to the next set of Data. I like to implement something like:

  1. Send Request with initial URL
  2. Extract URL if available (save initial url and extrated url)
  3. Send Request with extrated URL, back to 2
  4. No URL - variable loop over the collected URLs and retrieve the Data

I think the Variable Condition Loop Node would be the best fit?

Or maybe it is possible to do it in one loop?

BR,
Sven

Hi @sven-abx , you probably want to use the Recursive Loop in this case, and you basically end the loop if there is no URL extracted anymore.

I don’t think you can send back the extracted URL to the next iteration with other loops.

2 Likes

hi @bruno29a,

thanks for your reply. looks like the recursive loop node is the right choice, but the loop end node failes with “Execute failed: Cell count in row “Row0#1” is not equal to length of column names array: 17 vs. 13”.

I think the problem is “Row#1” and is switches from Row0 (Varible with URL) to “Row0#1” when the URL is empty/not found.

BR,
Sven

Hello @sven-abx,

Try this in the “Recursive End loop” :

Notice that, only the last iteration will be available at the end of the loop.

Br,
Samir

hi,

thanks for your help @SamirAbida. currently i try to figure out how to handle the link(#n) after every itereation to check if a link is extracted or not.

br,
sven

Hi @sven-abx,

Could you share some example (even dummy data) that I can understand your problem ?

Thanks,
Br,
Samir

1 Like

Hi @SamirAbida,

sorry, I have now data to share. I talking about:
image

First iteration retrieves @odata.nextLink, the second iteration is @odata.nextLink(#1), third will be @odata.nextLink(#2) and so on.

br,
sven

Hello @sven-abx,

did you have any progress? In case not maybe these two topics can help you out:

Br,
Ivan

3 Likes

hi @ipazin,
thanks for you reply. The first one looks promising and I was building something simliar.

Thanks and have a nice day,

BR,
Sven

2 Likes

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.