<?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: Need help getting basic requests.post to work for HTTP Event Collector with Python in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Need-help-getting-basic-requests-post-to-work-for-HTTP-Event/m-p/258289#M3214</link>
    <description>&lt;P&gt;Here is my solution to the problem:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;#!/usr/bin/python

import requests
import json

url='https://172.16.x.y:8088/services/collector/event'
authHeader = {'Authorization': 'Splunk super_sekrit'}
jsonDict = {"event": "through python -- again - does this thing work"}

r = requests.post(url, headers=authHeader, json=jsonDict, verify=False)
print r.text
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Thu, 20 Oct 2016 13:36:47 GMT</pubDate>
    <dc:creator>icrushservers</dc:creator>
    <dc:date>2016-10-20T13:36:47Z</dc:date>
    <item>
      <title>Need help getting basic requests.post to work for HTTP Event Collector with Python</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Need-help-getting-basic-requests-post-to-work-for-HTTP-Event/m-p/258288#M3213</link>
      <description>&lt;P&gt;OK - This is starting to frustrate me.&lt;/P&gt;

&lt;P&gt;I first tried the following command:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;curl -k  &lt;A href="http://10.10.XX.XX:8088/services/collector/event" target="test_blank"&gt;http://10.10.XX.XX:8088/services/collector/event&lt;/A&gt; -H "Authorization: Splunk my_correct_token" -d '{"event": "does this thing work"}'
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and it works correctly and the event is received.  Cool!&lt;/P&gt;

&lt;P&gt;Then I saw the following blog post on building HTTP Events with Python and while I could get the code to execute without error.  I could not get the system to receive the event.&lt;/P&gt;

&lt;P&gt;Breaking down the event to its most basic components in Python 2.7 I wrote the following code&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import requests

requests.post('http://10.10.XX.XX:8088/services/collector/event', headers={'Authorization': 'Splunk my_correct_token}, data = {"event": "through python -- again - does this thing work"})
print "does this thing work"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And while the code runs without error I am not receiving the events in Splunk.&lt;/P&gt;

&lt;P&gt;Any ideas?&lt;/P&gt;

&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Sun, 04 Sep 2016 19:30:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Need-help-getting-basic-requests-post-to-work-for-HTTP-Event/m-p/258288#M3213</guid>
      <dc:creator>voninski</dc:creator>
      <dc:date>2016-09-04T19:30:26Z</dc:date>
    </item>
    <item>
      <title>Re: Need help getting basic requests.post to work for HTTP Event Collector with Python</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Need-help-getting-basic-requests-post-to-work-for-HTTP-Event/m-p/258289#M3214</link>
      <description>&lt;P&gt;Here is my solution to the problem:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;#!/usr/bin/python

import requests
import json

url='https://172.16.x.y:8088/services/collector/event'
authHeader = {'Authorization': 'Splunk super_sekrit'}
jsonDict = {"event": "through python -- again - does this thing work"}

r = requests.post(url, headers=authHeader, json=jsonDict, verify=False)
print r.text
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 20 Oct 2016 13:36:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Need-help-getting-basic-requests-post-to-work-for-HTTP-Event/m-p/258289#M3214</guid>
      <dc:creator>icrushservers</dc:creator>
      <dc:date>2016-10-20T13:36:47Z</dc:date>
    </item>
    <item>
      <title>Re: Need help getting basic requests.post to work for HTTP Event Collector with Python</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Need-help-getting-basic-requests-post-to-work-for-HTTP-Event/m-p/258290#M3215</link>
      <description>&lt;P&gt;This works great.  And i like the fact that it separates the components needed.  Thank you!&lt;/P&gt;</description>
      <pubDate>Thu, 20 Oct 2016 14:13:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Need-help-getting-basic-requests-post-to-work-for-HTTP-Event/m-p/258290#M3215</guid>
      <dc:creator>voninski</dc:creator>
      <dc:date>2016-10-20T14:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: Need help getting basic requests.post to work for HTTP Event Collector with Python</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Need-help-getting-basic-requests-post-to-work-for-HTTP-Event/m-p/258291#M3216</link>
      <description>&lt;P&gt;But how can you pass this kind of authorization ('Splunk super_sekrit') if I am using the Java Splunk sdk ? I can't set a header over there. so How can I pass over there?&lt;/P&gt;</description>
      <pubDate>Wed, 18 Oct 2017 16:57:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Need-help-getting-basic-requests-post-to-work-for-HTTP-Event/m-p/258291#M3216</guid>
      <dc:creator>neeldesai1992</dc:creator>
      <dc:date>2017-10-18T16:57:47Z</dc:date>
    </item>
  </channel>
</rss>

