Solved

How to call a transformer every N times - HTTPCaller

  • 13 April 2021
  • 6 replies
  • 6 views

Badge +10

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

icon

Best answer by david_r 13 April 2021, 12:25

View original

6 replies

Userlevel 4

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.

Badge +10

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

Badge

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?

Userlevel 4

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.

Userlevel 5
Badge +29

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

Userlevel 4

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.

Reply