Issues with delete API end point - Error when record not found

Options

Hello All

I have an API end point that takes in an ID, and then deletes records using direct query from two relational tables (i.e. table1_table2, with table1_id and table2_id as fields, and table1_table3, with table1_id and table3_id as fields), and then finally from the primary table (table 1 from the above examples).

It runs fine if I provide it with an ID that exists. However, when I provide it an ID that doesn't exist, rather than gracefully do nothing, I get an error/exception thrown.

"Whoops! An error occurred.Exception: Not Found"

I have no response type set for the API. There are default output settings using the "Delete Record" option for the third and final call, rather than a direct database query. While I think I could probably just change that to a direct database query as well and avoid the issue, I'd like to know what I'm doing wrong as I can't imagine this is intended behavior.

Thank you

Comments

  • Liz Anaya
    Liz Anaya Member, Administrator

    ADMIN

    Options

    Hi @taxanouser! 👋

    Welcome to the Xano Community! 🎉

    If the ID provided doesn't exit, there will be an error. Normally, when an error occurs in the function stack, execution is halted entirely. If you want to deploy some customized error handling to change this behavior, you can do so by placing this function inside of a Try/Catch statement.

    Check out the documentation HERE. It provides an example of how to implement Try/ Catch when trying to delete a file that does not exist.

    Let me know if this helps! 😊