Hey,
I'm trying to make some flows more robust and efficient.
I have a flow that runs at a specific time every day and loops through up to 1000 iterations.
For each iteration, I'm making API calls against a REST API, retrieving a bearer token and then making the api call.
The tokens have a lease time of 3 minutes, so it would be more efficient, if I create two variables (one for the token and one for the ticks when it was created / I have 10 different endpoints, so it will be more like 20 variables) and then have each iteration check if more than 2:40 have passed since the creation of the token and refresh the variables only if needed.
Now, my issue is: if the second HTTP action (the actual call I want to make) fails, I want it to check again if too much time has passed. So, the retry policy in Power Automate doesn't cut it.
My questions are: How would you solve the token refresh on server errors in the API and do you think working with variables is a good idea, or should I just store the values in a SharePoint list without worrying about the 10 different servers?