<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Handling API responses in Perl in APIs</title>
    <link>https://community.cisco.com/t5/apis/handling-api-responses-in-perl/m-p/4875801#M6</link>
    <description>&lt;DIV class="duo-migrated-content"&gt;&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I am working on a few Perl scripts using the Duo::API module from GitHub.  I am mostly using &lt;CODE&gt;json_api_call()&lt;/CODE&gt; 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 &lt;CODE&gt;croak($msg)&lt;/CODE&gt; in the &lt;CODE&gt;parse_json_response()&lt;/CODE&gt; function.&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;&lt;/DIV&gt;</description>
    <pubDate>Wed, 02 Feb 2022 15:03:11 GMT</pubDate>
    <dc:creator>d_a_parker</dc:creator>
    <dc:date>2022-02-02T15:03:11Z</dc:date>
    <item>
      <title>Handling API responses in Perl</title>
      <link>https://community.cisco.com/t5/apis/handling-api-responses-in-perl/m-p/4875801#M6</link>
      <description>&lt;DIV class="duo-migrated-content"&gt;&lt;P&gt;Hello,&lt;/P&gt;
&lt;P&gt;I am working on a few Perl scripts using the Duo::API module from GitHub.  I am mostly using &lt;CODE&gt;json_api_call()&lt;/CODE&gt; 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 &lt;CODE&gt;croak($msg)&lt;/CODE&gt; in the &lt;CODE&gt;parse_json_response()&lt;/CODE&gt; function.&lt;/P&gt;
&lt;P&gt;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.&lt;/P&gt;
&lt;P&gt;Thanks!&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 02 Feb 2022 15:03:11 GMT</pubDate>
      <guid>https://community.cisco.com/t5/apis/handling-api-responses-in-perl/m-p/4875801#M6</guid>
      <dc:creator>d_a_parker</dc:creator>
      <dc:date>2022-02-02T15:03:11Z</dc:date>
    </item>
    <item>
      <title>Re: Handling API responses in Perl</title>
      <link>https://community.cisco.com/t5/apis/handling-api-responses-in-perl/m-p/4875802#M7</link>
      <description>&lt;DIV class="duo-migrated-content"&gt;&lt;P&gt;Hi &lt;A class="mention" href="https://community.duo.com/u/d_a_parker"&gt;@d_a_parker&lt;/A&gt;, 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 &lt;A href="https://help.duo.com/s/article/1338"&gt;article that explains the Duo API responses and error messages&lt;/A&gt; 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!&lt;/P&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 07 Feb 2022 21:34:20 GMT</pubDate>
      <guid>https://community.cisco.com/t5/apis/handling-api-responses-in-perl/m-p/4875802#M7</guid>
      <dc:creator>Amy2</dc:creator>
      <dc:date>2022-02-07T21:34:20Z</dc:date>
    </item>
  </channel>
</rss>

