Support Questions

Find answers, ask questions, and share your expertise
Announcements
Celebrating as our community reaches 100,000 members! Thank you!

How to loop on InvokeHttp until a condition is true in Apache NIFI?

avatar
Explorer

I have 2 API's when I will call First API, I'll get an ID in it. After that I'll call 2nd API using that ID and get a SUBID in it, Then I'll call 2nd API again with that SubId(it will be considered as ID for API this time) and get an SubId in it.

 

I'll keep doing that until SUBID is empty. I mean until I get an empty array. I have to call API on loop. 

 

So how can I call a conditional loop on InvokeHttp. Please answer with nifi processors. 

1 REPLY 1

avatar
Super Mentor

@anony   

Let me see if i understand correctly your use case.

InvokeHTTP (number 1) --> InvokeHTTP (number 2) -->loops back on invokeHTTP (number 2) until subId is empty and then exits loop?

So InvokeHTTP1 makes initial call to get ID (ID-Orig).
ID-Orig is then used by the second InvokeHTTP2 which may or may not have a return with a subID.
Use new SubID each time to make another InvokeHTTP2 execution until return no longer has a SubID.
correct?

After invokeHTTP2, extract that SubID to a FlowFile attribute (SubID) --> RouteOnAttribute (use to valdiate attribute SubID is not null) --> IF NOT null send FlowFile back to invokeHTTP and IF null have FlowFile exit loop.

If you found that the provided solution(s) assisted you with your query, please take a moment to login and click Accept as Solution below each response that helped.


Thank you,

Matt