Api processing question

I have an API that gets submitted and returns a batch ID number.
The batch then will return a result, but i can take up to 2 to 3 minutes before the result is available via the API.

Is there a way to run the API in a loop until the result is processed?

I tried to run a condition statement, but it only seemed to run the API one time and didn’t keep it running until a result.

There is a ‘success’ option that is initially set to false until the results are published, and then it triggers to a ‘true’ value, but even when i run a repeat condition based on that value, it only seems to cycle through the API results one time while its still a false.

Any suggestions on how to get this accomplished on the Server side?

here is how i currently have it setup, but its not returning the results

have you tried using the do…while loop?

I did try this process however my issue is that I am checking a status that is originally false. So if I setup a While loop checking the status…how would i get it to then perform a function once the status changes from False to True?

I don’t think the While loop would allow such a function.

Set Value global status = false
While (global) status == false:

  • Wait 10000 (milliseconds)
  • API Action
  • Set Value global status from API Action data

And then you put the rest of your script outside the while loop. The script will hang at the while loop while status is false

that sounds like it would work, but how do you get the server function to ‘wait’ that time period. Would that be a custom script function or is that something that Wappler has in its arsenal?

I think it's something Wappler has in its arsenal, it's an action called "Wait"

If not, grab it here: