<?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 Using Splunk REST API to run a search giving &amp;quot;401 Unauthorized Error&amp;quot; in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Using-Splunk-REST-API-to-run-a-search-giving-quot-401/m-p/41262#M499</link>
    <description>&lt;P&gt;I am using REST API from python script and use the following link as an example&lt;/P&gt;

&lt;P&gt;&lt;A href="http://blogs.splunk.com/2011/08/02/splunk-rest-api-is-easy-to-use/comment-page-1/#comment-63962"&gt;http://blogs.splunk.com/2011/08/02/splunk-rest-api-is-easy-to-use/comment-page-1/#comment-63962&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;But I am getting some error when i run this.&lt;BR /&gt;
The Error in Step 3 is the following.&lt;/P&gt;

&lt;P&gt;**====&amp;gt;sid: 1335953526.93 &amp;lt;====&lt;/P&gt;

&lt;P&gt;/services/search/jobs/1335953526.93/&lt;/P&gt;

&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;
File “C:/Python2.7/Examples/diveintopython-examples-5.4/diveintopython-5.4/py/login_script.py”, line 67, in&lt;/P&gt;

&lt;P&gt;isdonestatus = isdonestatus.search(searchstatus).groups()[0]&lt;/P&gt;

&lt;P&gt;AttributeError: ‘NoneType’ object has no attribute ‘groups’&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;** &lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;And if I skip Step 3 and execute Step 4 i get the following "401 Unauthorized" error&lt;/P&gt;

&lt;P&gt;e1e8a79b76386f63cf2e692562b52baf&lt;/P&gt;

&lt;P&gt;====&amp;gt;sid:  1335953707.93  &amp;lt;====&lt;/P&gt;

&lt;P&gt;====&amp;gt;search result:  [401 Unauthorized.]  &amp;lt;====&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Can you help me resolve this?&lt;/P&gt;</description>
    <pubDate>Wed, 02 May 2012 10:35:16 GMT</pubDate>
    <dc:creator>hiteshkanchan</dc:creator>
    <dc:date>2012-05-02T10:35:16Z</dc:date>
    <item>
      <title>Using Splunk REST API to run a search giving "401 Unauthorized Error"</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Using-Splunk-REST-API-to-run-a-search-giving-quot-401/m-p/41262#M499</link>
      <description>&lt;P&gt;I am using REST API from python script and use the following link as an example&lt;/P&gt;

&lt;P&gt;&lt;A href="http://blogs.splunk.com/2011/08/02/splunk-rest-api-is-easy-to-use/comment-page-1/#comment-63962"&gt;http://blogs.splunk.com/2011/08/02/splunk-rest-api-is-easy-to-use/comment-page-1/#comment-63962&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;But I am getting some error when i run this.&lt;BR /&gt;
The Error in Step 3 is the following.&lt;/P&gt;

&lt;P&gt;**====&amp;gt;sid: 1335953526.93 &amp;lt;====&lt;/P&gt;

&lt;P&gt;/services/search/jobs/1335953526.93/&lt;/P&gt;

&lt;P&gt;Traceback (most recent call last):&lt;BR /&gt;
File “C:/Python2.7/Examples/diveintopython-examples-5.4/diveintopython-5.4/py/login_script.py”, line 67, in&lt;/P&gt;

&lt;P&gt;isdonestatus = isdonestatus.search(searchstatus).groups()[0]&lt;/P&gt;

&lt;P&gt;AttributeError: ‘NoneType’ object has no attribute ‘groups’&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;P&gt;** &lt;/P&gt;
&lt;/BLOCKQUOTE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;And if I skip Step 3 and execute Step 4 i get the following "401 Unauthorized" error&lt;/P&gt;

&lt;P&gt;e1e8a79b76386f63cf2e692562b52baf&lt;/P&gt;

&lt;P&gt;====&amp;gt;sid:  1335953707.93  &amp;lt;====&lt;/P&gt;

&lt;P&gt;====&amp;gt;search result:  [401 Unauthorized.]  &amp;lt;====&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;BLOCKQUOTE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;/BLOCKQUOTE&gt;
&lt;/BLOCKQUOTE&gt;

&lt;P&gt;Can you help me resolve this?&lt;/P&gt;</description>
      <pubDate>Wed, 02 May 2012 10:35:16 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Using-Splunk-REST-API-to-run-a-search-giving-quot-401/m-p/41262#M499</guid>
      <dc:creator>hiteshkanchan</dc:creator>
      <dc:date>2012-05-02T10:35:16Z</dc:date>
    </item>
    <item>
      <title>Re: Using Splunk REST API to run a search giving "401 Unauthorized Error"</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Using-Splunk-REST-API-to-run-a-search-giving-quot-401/m-p/41263#M500</link>
      <description>&lt;P&gt;The sid is returned properly in step 2 but the step 3 below fails&lt;BR /&gt;
giving the error "AttributeError: ‘NoneType’ object has no attribute ‘groups’"&lt;/P&gt;

&lt;P&gt;Step 3: Get the search status&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;myhttp.add_credentials(username, password)

servicessearchstatusstr = '/services/search/jobs/%s/' % sid

isnotdone = True

while isnotdone:

    searchstatus = myhttp.request(baseurl + servicessearchstatusstr, 'GET')[1]
    isdonestatus = re.compile('isDone"&amp;gt;(0|1)')
    isdonestatus = isdonestatus.search(searchstatus).groups()[0]
    if (isdonestatus == '1'):
        isnotdone = False
print "====&amp;gt;search status:  %s  &amp;lt;====" % isdonestatus
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 02 May 2012 18:56:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Using-Splunk-REST-API-to-run-a-search-giving-quot-401/m-p/41263#M500</guid>
      <dc:creator>hiteshkanchan</dc:creator>
      <dc:date>2012-05-02T18:56:50Z</dc:date>
    </item>
    <item>
      <title>Re: Using Splunk REST API to run a search giving "401 Unauthorized Error"</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Using-Splunk-REST-API-to-run-a-search-giving-quot-401/m-p/41264#M501</link>
      <description>&lt;P&gt;This problem comes due to authentication problem. Once we set proper aothorization it gets resolved&lt;/P&gt;</description>
      <pubDate>Fri, 25 May 2012 12:19:58 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Using-Splunk-REST-API-to-run-a-search-giving-quot-401/m-p/41264#M501</guid>
      <dc:creator>hiteshkanchan</dc:creator>
      <dc:date>2012-05-25T12:19:58Z</dc:date>
    </item>
  </channel>
</rss>

