<?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: How to send json data via HEC in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-send-json-data-via-HEC/m-p/460892#M79558</link>
    <description>&lt;P&gt;Thanks. I tried using your script but it didnt work. The error message was "Could not find a suitable TLS CA certificate bundle, invalid path: False"&lt;/P&gt;

&lt;P&gt;Is dictVar the variable that you have defined for the json results? If so, I replaced it with mine which is server_info.&lt;/P&gt;</description>
    <pubDate>Fri, 22 May 2020 05:59:08 GMT</pubDate>
    <dc:creator>timyong80</dc:creator>
    <dc:date>2020-05-22T05:59:08Z</dc:date>
    <item>
      <title>How to send json data via HEC</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-send-json-data-via-HEC/m-p/460890#M79556</link>
      <description>&lt;P&gt;I am using a Python script to send data to Splunk via HEC. There's no problem when curling a simple "Hello World".&lt;BR /&gt;
However, I would like to curl search results (json format) obtained via a Python script. Here's how the snippet of the Python script to get the results in json format.&lt;/P&gt;

&lt;P&gt;&lt;IMG src="https://community.splunk.com/storage/temp/290805-python.jpg" alt="alt text" /&gt;&lt;/P&gt;

&lt;P&gt;The results look like this:&lt;/P&gt;

&lt;P&gt;{'_id': {'$oid': '5ec4f96e67ac75656af5ea5b'}, 'created_at': '2020-05-10T09:33:33.490855', 'appid_caller': 'fg67k78k-7f44-5c90-a1b6-42gf5jjjj00a', 'input': {'target_host': 'portal-azure.cloud.io',&lt;BR /&gt;
'target_port': 443}, 'output': {'result': False, 'info': 'Application has failed security checks. Drill down the results [array] to find  information.', 'results': [{'category': 'hosting', 'result': False, 'title': 'Insecure use of shared hosting subdomain', 'description': "The application uses shared hosting parent domain. Recommended to use (e.g.: *.abc.com, *.abc.cloud, etc).", 'cwe': 348, 'checks': []}]}}&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Question is&lt;/STRONG&gt;: how do I curl the results (server_info) using HEC? I'm getting an error 400. I'm guessing the problem lies with the 'data' variable where it may not be defined properly. Also, I've tried the endpoints; &lt;STRONG&gt;services/collector&lt;/STRONG&gt; and &lt;STRONG&gt;services/collector/event&lt;/STRONG&gt; but none worked. When using &lt;STRONG&gt;services/collector/raw&lt;/STRONG&gt; endpoint, I did get a response code 200 which indicated successful but jargon data was displayed in Splunk.  Below is the post script used.&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;splunk_headers = {'Authorization': 'Splunk f5t34545-xxxxxc-xxxx-xxxx-xxxx-xxxxxxxx'}&lt;BR /&gt;
data = {"sourcetype": "server","event": server_info}&lt;BR /&gt;
response = requests.post('&lt;A href="https://server03.na.abc.com:8088/services/collector/event" target="_blank"&gt;https://server03.na.abc.com:8088/services/collector/event&lt;/A&gt;', headers=splunk_headers, data=data, verify=False)&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 05:31:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-send-json-data-via-HEC/m-p/460890#M79556</guid>
      <dc:creator>timyong80</dc:creator>
      <dc:date>2020-09-30T05:31:25Z</dc:date>
    </item>
    <item>
      <title>Re: How to send json data via HEC</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-send-json-data-via-HEC/m-p/460891#M79557</link>
      <description>&lt;P&gt;Try setting Content-Type 'application/json' in the headers. This is an example I'm doing using Python requests module.&lt;/P&gt;

&lt;P&gt;requests.post("&lt;A href="https://hec-server:8088/services/collector"&gt;https://hec-server:8088/services/collector&lt;/A&gt;", headers={'Authorization': 'Splunk xxxxxxxxxxxxxxxx','Content-Type': 'application/json'}, data=json.dumps({'event': dictVar}), verify="False")&lt;/P&gt;</description>
      <pubDate>Fri, 22 May 2020 00:58:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-send-json-data-via-HEC/m-p/460891#M79557</guid>
      <dc:creator>anthonymelita</dc:creator>
      <dc:date>2020-05-22T00:58:03Z</dc:date>
    </item>
    <item>
      <title>Re: How to send json data via HEC</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-send-json-data-via-HEC/m-p/460892#M79558</link>
      <description>&lt;P&gt;Thanks. I tried using your script but it didnt work. The error message was "Could not find a suitable TLS CA certificate bundle, invalid path: False"&lt;/P&gt;

&lt;P&gt;Is dictVar the variable that you have defined for the json results? If so, I replaced it with mine which is server_info.&lt;/P&gt;</description>
      <pubDate>Fri, 22 May 2020 05:59:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-send-json-data-via-HEC/m-p/460892#M79558</guid>
      <dc:creator>timyong80</dc:creator>
      <dc:date>2020-05-22T05:59:08Z</dc:date>
    </item>
  </channel>
</rss>

