Skip to main content
Solved

How to call a transformer every N times - HTTPCaller

  • April 13, 2021
  • 6 replies
  • 71 views

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

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.

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

6 replies

david_r
Celebrity
  • 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+14
  • 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

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
Celebrity
  • April 13, 2021

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+65
  • Celebrity
  • 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.

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
Celebrity
  • April 15, 2021

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.