Skip to main content
Solved

How to call a transformer every N times - HTTPCaller


oliver.morris
Contributor
Forum|alt.badge.img+12

Hi, I make many requests to a webservice using HTTPCaller, the trouble is that the credentials expire after 5 minutes.

 

I use one HTTPCaller to obtain a new API token and then I use another HTTPCaller to get the required data back.

 

In that time the token is valid I can run at least 100 calls to the service. What transformers can I use to ensure that after every 100 calls I call the HTTPCaller to get a new API Token and then use that token in the other HTTPCaller to get the data.

 

I was thinking loops and test filters but I can't get the logic this morning. Any help would be very appreciated.

 

Thanks

Best answer by david_r

I would try a custom looping transformer along a concept such as this:

httploopOf course this is just the general idea, you'll probably need a few more transformers to handle attributes, results, etc.

View original
Did this help you find an answer to your question?

6 replies

david_r
Evangelist
  • Best Answer
  • April 13, 2021

I would try a custom looping transformer along a concept such as this:

httploopOf course this is just the general idea, you'll probably need a few more transformers to handle attributes, results, etc.


oliver.morris
Contributor
Forum|alt.badge.img+12
  • Author
  • Contributor
  • April 13, 2021

Thanks for the help @david_r​ this makes sense, just a case of trying to get my head around loops again!


Forum|alt.badge.img
  • April 13, 2021
david_r wrote:

I would try a custom looping transformer along a concept such as this:

httploopOf course this is just the general idea, you'll probably need a few more transformers to handle attributes, results, etc.

Would this combine the data from each separate request into one cohesive dataset? Or would it only take the last data response?


david_r
Evangelist
  • April 13, 2021
msanders wrote:

Would this combine the data from each separate request into one cohesive dataset? Or would it only take the last data response?

Good question. This isn't quite solved in the quick-and-dirty "illustration" I did above, which is mostly looking to give ideas on how to solve the token issue. But if you search for "httpcaller loop" on the forums here you'll find some examples that are a bit more complete in this regard.


hkingsbury
Celebrity
Forum|alt.badge.img+51
  • Celebrity
  • April 13, 2021
david_r wrote:

I would try a custom looping transformer along a concept such as this:

httploopOf course this is just the general idea, you'll probably need a few more transformers to handle attributes, results, etc.

You'd want to make sure you add some logic between the <Rejected> port and the loop to make sure you only loop when you have a token issue. Other wise you'd be at risk of an endless loop


david_r
Evangelist
  • April 15, 2021
hkingsbury wrote:

You'd want to make sure you add some logic between the <Rejected> port and the loop to make sure you only loop when you have a token issue. Other wise you'd be at risk of an endless loop

Yes, definitely. This is by all means not a complete solution, it needs to be fleshed out.


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings