Question

Make the HTTPCaller stops when I have what I need

  • 19 December 2018
  • 6 replies
  • 1 view

Badge +8

Let's say I have 10 features and each of them has an URL that I can use within a HTTPCaller.

If I have what I need within the first URL though (validation made by a Tester just after), I want the HTTPCaller stop making calls.

How could I do that?

Thanks!


6 replies

Badge +22

How about using a variableRetriever, tester on the value of the variable, httpCaller, tester on the results of the call, variableSetter if you have what you need.

Userlevel 4
If your http endpoint supports paging, you could wrap the HTTPCaller into a looping custom transformer that asks for e.g. successive blocks of 10 features, until you've found what you needed.
Badge +8

How about using a variableRetriever, tester on the value of the variable, httpCaller, tester on the results of the call, variableSetter if you have what you need.

I have to be honest with you, I've never used those variable transformers.

I've read the help documentation about them but I'm still confused how to use it.

I will try to find some examples here.

Happy Christmas!

Badge +22

I have to be honest with you, I've never used those variable transformers.

I've read the help documentation about them but I'm still confused how to use it.

I will try to find some examples here.

Happy Christmas!

Here is a basic workspace illustrating the idea.

 

kb_HTTPCallerStop.fmw

Badge +8

Here is a basic workspace illustrating the idea.

 

kb_HTTPCallerStop.fmw

WoW ! Thanks a lot! I'll check this out early 2019 :D

Userlevel 4
Badge +25

It did occur to me that there is a quicker solution, depending on what happens to the feature that passes the test. If it just goes on to transformers that are feature-based (i.e. it can be processed by itself) then you could simply end that stream with a Terminator transformer.

So the passing feature would get processed and then shut down the workspace, before other features get to the HTTPCaller.

Other than that, yes, I think variables or loops are the way forward (as much as it pains me to have to suggest variables - but at least this is a valid use of them!)

The only other way I can think of is to cause the HTTPCaller to reject features. For example if the response body is saved to a file, and the first passed feature could somehow set that file to read-only, then the rest of the HTTP calls would fail (they would still happen, but they would probably be output as Rejected, if that helps).

Reply