<?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 Re: Yet another 401 Error from Prime REST API in Controllers</title>
    <link>https://community.cisco.com/t5/controllers/resolved-yet-another-401-error-from-prime-rest-api/m-p/3575678#M1231</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Were no changes made to either the script or Prime?&amp;nbsp; If not, then please check to ensure your script is not using persistent connections.&amp;nbsp; If you're using non-local AAA (like TACACS), try increasing the retry count and timeout that you have configured in Prime.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 23 Feb 2016 20:36:54 GMT</pubDate>
    <dc:creator>Spencer Zier</dc:creator>
    <dc:date>2016-02-23T20:36:54Z</dc:date>
    <item>
      <title>[RESOLVED] Yet another 401 Error from Prime REST API</title>
      <link>https://community.cisco.com/t5/controllers/resolved-yet-another-401-error-from-prime-rest-api/m-p/3575676#M1229</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a similar issue with Prime 2.2.3's REST API like these two cases:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" class="unlinked" title="https://communities.cisco.com/thread/63660 https://communities.cisco.com/thread/61982"&gt;https://communities.cisco.com/thread/63660&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" class="unlinked" title="https://communities.cisco.com/thread/61982"&gt;https://communities.cisco.com/thread/61982&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, the 401 (Not authorized) only occurs when I run my &lt;A href="https://github.com/ww9rivers/netopy/blob/master/cisco/pi/__init__.py" title="Python script"&gt;Python script&lt;/A&gt;, which uses Python's request module. My debug log shows the API it tried to access is:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;A _jive_internal="true" href="https://community.cisco.com/" rel="nofollow" target="_blank"&gt;https://&lt;/A&gt;&lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;EM&gt;prime-server&lt;/EM&gt;&amp;gt;/webacs/api/v1/data/Devices.json, params={'.full': 'true'}, verify=False&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I test the REST API point using Firefox's RESTClient, it worked fine:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Request:&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;URL: &lt;A class="unlinked" title="https://prime01.mcit.med.umich.edu/webacs/api/v1/data/Devices.json?.full=true"&gt;https://&amp;lt;&lt;EM&gt;prime-server&lt;/EM&gt;&amp;gt;/webacs/api/v1/data/Devices.json?.full=true&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Response headers:&lt;/P&gt;&lt;PRE class="jive-pre"&gt;&lt;OL class="linenums"&gt;
&lt;LI&gt;&lt;SPAN class="line"&gt;&lt;SPAN class="header-name"&gt;Status Code&lt;/SPAN&gt;&lt;SPAN class="header-split"&gt;: &lt;/SPAN&gt;&lt;SPAN class="header-value"&gt;200 OK&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN class="line"&gt;&lt;SPAN class="header-name"&gt;Cache-Control&lt;/SPAN&gt;&lt;SPAN class="header-split"&gt;: &lt;/SPAN&gt;&lt;SPAN class="header-value"&gt;private&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN class="line"&gt;&lt;SPAN class="header-name"&gt;Content-Range&lt;/SPAN&gt;&lt;SPAN class="header-split"&gt;: &lt;/SPAN&gt;&lt;SPAN class="header-value"&gt;instances 0-99/1428&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN class="line"&gt;&lt;SPAN class="header-name"&gt;Content-Type&lt;/SPAN&gt;&lt;SPAN class="header-split"&gt;: &lt;/SPAN&gt;&lt;SPAN class="header-value"&gt;application/json&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN class="line"&gt;&lt;SPAN class="header-name"&gt;Date&lt;/SPAN&gt;&lt;SPAN class="header-split"&gt;: &lt;/SPAN&gt;&lt;SPAN class="header-value"&gt;Tue, 23 Feb 2016 18:43:23 GMT&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN class="line"&gt;&lt;SPAN class="header-name"&gt;Expires&lt;/SPAN&gt;&lt;SPAN class="header-split"&gt;: &lt;/SPAN&gt;&lt;SPAN class="header-value"&gt;Wed, 31 Dec 1969 19:00:00 EST&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN class="line"&gt;&lt;SPAN class="header-name"&gt;Server&lt;/SPAN&gt;&lt;SPAN class="header-split"&gt;: &lt;/SPAN&gt;&lt;SPAN class="header-value"&gt;Apache-Coyote/1.1&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN class="line"&gt;&lt;SPAN class="header-name"&gt;Transfer-Encoding&lt;/SPAN&gt;&lt;SPAN class="header-split"&gt;: &lt;/SPAN&gt;&lt;SPAN class="header-value"&gt;chunked&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;&lt;SPAN class="line"&gt;&lt;SPAN class="header-name"&gt;X-NBI-TIME&lt;/SPAN&gt;&lt;SPAN class="header-split"&gt;: &lt;/SPAN&gt;&lt;SPAN class="header-value"&gt;89&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;/OL&gt;&lt;/PRE&gt;&lt;P&gt;My Python script has been run as a daily cron job, collecting information from two Prime servers. The script has worked fine on both Prime servers until 2/19, when one of the two server started to respond with 401.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance for any insights.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;[Update] -- &lt;/STRONG&gt;It seems that I cannot reply to this post in any way, so I'll try updating it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It turned out that I had two issues: a 401 error, which was resolved by restarting the Prime service.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Then, there was a 503 error after 5 requests / responses, which led me back to look at post 63660 again: I thought my code was not sending "Connection: keep-alive", but a little more debugg log from Python's HTTP mode revealed that something did that on my behalf.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So I added a line in my code to explicitly send the "Connection: close" header as post 63660 suggested: That did the trick for me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;As for Prime itself: My networking guys told me that no change had been made. I suspect that some OS patching on the box may have changed the underlying Python library to add in that "Connection: keep-alive" header.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: ww9rivers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Feb 2016 19:16:07 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/resolved-yet-another-401-error-from-prime-rest-api/m-p/3575676#M1229</guid>
      <dc:creator>ww9rivers</dc:creator>
      <dc:date>2016-02-23T19:16:07Z</dc:date>
    </item>
    <item>
      <title>Re: Yet another 401 Error from Prime REST API</title>
      <link>https://community.cisco.com/t5/controllers/resolved-yet-another-401-error-from-prime-rest-api/m-p/3575677#M1230</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;That URL looks bad to me.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.cisco.com/" onclick="" rel="nofollow" target="_blank"&gt;&lt;SPAN style="color: #0a63a7; text-decoration: underline;"&gt;https://&lt;/SPAN&gt;&lt;/A&gt;&amp;lt;&lt;EM&gt;prime-server&lt;/EM&gt;&amp;gt;/webacs/api/v1/data/Devices.json, params={'.full': 'true'}, verify=False&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Shouldn't the "verify=False" be part of the definition of the REST URL inside your Python script to prevent verifying the SSL certificate, and not part of the actual GET request? I would also look at the definition of the URL in your Python script to get rid of those braces - Prime might be enabling an attack-protection routine. And even if the braces weren't there, I'm not sure the parameter format is valid for a URL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think Prime should see the URL that it receives should be formatted like this:&lt;/P&gt;&lt;P&gt;&lt;A _jive_internal="true" href="https://community.cisco.com/" onclick="" rel="nofollow" target="_blank"&gt;/&lt;/A&gt;&lt;A href="https://&amp;lt;prime-server&amp;gt;/webacs/api/v1/data/Devices.json?.full=true"&gt;https://&lt;/A&gt;&lt;A&gt;&lt;/A&gt;&lt;A&gt;&lt;/A&gt;&lt;A&gt;&amp;lt;&lt;EM&gt;prime-server&lt;/EM&gt;&amp;gt;/webacs/api/v1/data/Devices.json?.full=true&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Feb 2016 20:11:51 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/resolved-yet-another-401-error-from-prime-rest-api/m-p/3575677#M1230</guid>
      <dc:creator>smp</dc:creator>
      <dc:date>2016-02-23T20:11:51Z</dc:date>
    </item>
    <item>
      <title>Re: Yet another 401 Error from Prime REST API</title>
      <link>https://community.cisco.com/t5/controllers/resolved-yet-another-401-error-from-prime-rest-api/m-p/3575678#M1231</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Were no changes made to either the script or Prime?&amp;nbsp; If not, then please check to ensure your script is not using persistent connections.&amp;nbsp; If you're using non-local AAA (like TACACS), try increasing the retry count and timeout that you have configured in Prime.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Feb 2016 20:36:54 GMT</pubDate>
      <guid>https://community.cisco.com/t5/controllers/resolved-yet-another-401-error-from-prime-rest-api/m-p/3575678#M1231</guid>
      <dc:creator>Spencer Zier</dc:creator>
      <dc:date>2016-02-23T20:36:54Z</dc:date>
    </item>
  </channel>
</rss>

