I've built a button that takes data from the selected row in a table and sends it to our production database via a Rest API. This works fine for most cases, but the lingering issue is that when the API fails, retool understands it instead as a success.
This is a challenge because I want to run user notifications and other actions upon failures, and different ones upon success.
In this screenshots we can see the API response comes back with an error:
The API is an internally built solution, so I can modify it. What do I need to do to get retool to understand it as a failure rather than a success in the response?
Happy to help out here and for this to work, you will want to configure your Rest API to return a status code to communicate if it was a success (200, etc.) or failure (400, etc.).
You can refer to this article here for API response codes to return depending on the outcome.
Retool will recognize these codes and respond accordingly.
Hope this helps and let me know if you have any additional questions!