<?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: Splunk HEC: Python post requests fails with 401 Unauthorized client error while cURL requests are fine in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-HEC-Python-post-requests-fails-with-401-Unauthorized/m-p/461151#M79601</link>
    <description>&lt;P&gt;@spervez, glad its working. If you think the above answer helped you to resolve the issue, accept/upvote.&lt;BR /&gt;
Also try the class mentioned by George below. That will definitely help you to get going.&lt;/P&gt;</description>
    <pubDate>Fri, 18 Oct 2019 13:41:43 GMT</pubDate>
    <dc:creator>renjith_nair</dc:creator>
    <dc:date>2019-10-18T13:41:43Z</dc:date>
    <item>
      <title>Splunk HEC: Python post requests fails with 401 Unauthorized client error while cURL requests are fine</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-HEC-Python-post-requests-fails-with-401-Unauthorized/m-p/461147#M79597</link>
      <description>&lt;P&gt;I have created a python script to post json data to Splunk:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;splunk_ep = 'https://xxx:8088/services/collector/event'
SPLUNK_TOKEN = os.getenv('SPLUNK_TOKEN')
auth_header = {'Authorization': SPLUNK_TOKEN, 'Content-Type': 'application/json'}

def SendToSplunk(data):
        response = requests.post(splunk_ep, json=data, headers=auth_header, verify = False)
        print(response)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;It returns following error:&lt;BR /&gt;
401 Client Error: Unauthorized for url: &lt;A href="https://xxx:8088/services/collector/event"&gt;https://xxx:8088/services/collector/event&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;However, If use cURL with above params, it works fine. Please advise.&lt;BR /&gt;
Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 01:20:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-HEC-Python-post-requests-fails-with-401-Unauthorized/m-p/461147#M79597</guid>
      <dc:creator>spervez</dc:creator>
      <dc:date>2019-10-16T01:20:25Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk HEC: Python post requests fails with 401 Unauthorized client error while cURL requests are fine</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-HEC-Python-post-requests-fails-with-401-Unauthorized/m-p/461148#M79598</link>
      <description>&lt;P&gt;@spervez,&lt;/P&gt;

&lt;P&gt;In the authorization header, you need to add the  &lt;STRONG&gt;Splunk&lt;/STRONG&gt; keyword &lt;CODE&gt;"Authorization: Splunk &amp;lt;hec_token&amp;gt;"&lt;/CODE&gt; . If your environment variable does not have this, try adding the keyword.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 11:09:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-HEC-Python-post-requests-fails-with-401-Unauthorized/m-p/461148#M79598</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2019-10-16T11:09:43Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk HEC: Python post requests fails with 401 Unauthorized client error while cURL requests are fine</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-HEC-Python-post-requests-fails-with-401-Unauthorized/m-p/461149#M79599</link>
      <description>&lt;P&gt;You could also use a pre-made HEC class.&lt;BR /&gt;
&lt;A href="https://github.com/georgestarcher/Splunk-Class-httpevent"&gt;https://github.com/georgestarcher/Splunk-Class-httpevent&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2019 12:34:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-HEC-Python-post-requests-fails-with-401-Unauthorized/m-p/461149#M79599</guid>
      <dc:creator>starcher</dc:creator>
      <dc:date>2019-10-16T12:34:09Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk HEC: Python post requests fails with 401 Unauthorized client error while cURL requests are fine</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-HEC-Python-post-requests-fails-with-401-Unauthorized/m-p/461150#M79600</link>
      <description>&lt;P&gt;Hi Renjith,&lt;BR /&gt;
Thanks for coming back. &lt;/P&gt;

&lt;P&gt;I have resolved the issue and it was a stupid error I was making in using keyword SPLUNK instead of Splunk.&lt;/P&gt;

&lt;P&gt;Regards&lt;/P&gt;</description>
      <pubDate>Thu, 17 Oct 2019 22:59:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-HEC-Python-post-requests-fails-with-401-Unauthorized/m-p/461150#M79600</guid>
      <dc:creator>spervez</dc:creator>
      <dc:date>2019-10-17T22:59:53Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk HEC: Python post requests fails with 401 Unauthorized client error while cURL requests are fine</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-HEC-Python-post-requests-fails-with-401-Unauthorized/m-p/461151#M79601</link>
      <description>&lt;P&gt;@spervez, glad its working. If you think the above answer helped you to resolve the issue, accept/upvote.&lt;BR /&gt;
Also try the class mentioned by George below. That will definitely help you to get going.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Oct 2019 13:41:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-HEC-Python-post-requests-fails-with-401-Unauthorized/m-p/461151#M79601</guid>
      <dc:creator>renjith_nair</dc:creator>
      <dc:date>2019-10-18T13:41:43Z</dc:date>
    </item>
  </channel>
</rss>

