Handling API responses in Perl

Hello,

I am working on a few Perl scripts using the Duo::API module from GitHub. I am mostly using json_api_call() and everything seems to work fine, except that if there is an error, the script just prints the API response message and dies. This seems to be from the call to croak($msg) in the parse_json_response() function.

My question is, what is the best way to check the API response and catch an error cleanly, instead of having it just bail out? I would ideally like to log the error and keep going.

Thanks!

Hi @d_a_parker, and welcome to the Duo Community! This doesn’t really help with the “log the error and keep going” part of your question, but we have an article that explains the Duo API responses and error messages that seems like it would be useful. Give it a look, and let me know if you have any additional questions. Hopefully, others who are more experienced in using our API can chime in to help!