<?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: Rest api error on get _raw events in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Rest-api-error-on-get-raw-events/m-p/567582#M10086</link>
    <description>&lt;P&gt;But what's the problem? It seems you're getting your events. It's not a splunk error, it's an error being the contents of an event (in this case - coming from ossec). Or am I missing something?&lt;/P&gt;</description>
    <pubDate>Mon, 20 Sep 2021 05:16:31 GMT</pubDate>
    <dc:creator>PickleRick</dc:creator>
    <dc:date>2021-09-20T05:16:31Z</dc:date>
    <item>
      <title>Rest api error on get _raw events</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Rest-api-error-on-get-raw-events/m-p/567568#M10085</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am experimenting with the REST api and pulling events with a script, It seems like authentication and search is pulling the correct events from the /results endpoint but i see an error on _raw events&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Error in events:&lt;/STRONG&gt;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;STRONG&gt;'_raw': 'Server: DC-C02SD43JG8WP, Error: Unable to run data '&lt;BR /&gt;'collection. Error: Password prompt encountered. '&lt;BR /&gt;'Aborting.',&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;#!/usr/local/bin/python3
# import time # need for sleep
from xml.dom import minidom

import time
import json, pprint

import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)


base_url = 'https://127.0.0.1:8089'
username = 'admin'
password = 'changeme'

search_query = "search=search index=main earliest=-4y"

r = requests.get(base_url+"/servicesNS/admin/search/auth/login",
    data={'username':username,'password':password}, verify=False)

session_key = minidom.parseString(r.text).getElementsByTagName('sessionKey')[0].firstChild.nodeValue
print ("Session Key:", session_key)

r = requests.post(base_url + '/services/search/jobs/', data=search_query,
    headers = { 'Authorization': ('Splunk %s' %session_key)},
    verify = False)

sid = minidom.parseString(r.text).getElementsByTagName('sid')[0].firstChild.nodeValue
print ("Search ID", sid)

done = False
while not done:
    r = requests.get(base_url + '/services/search/jobs/' + sid,
        headers = { 'Authorization': ('Splunk %s' %session_key)},
        verify = False)
    response = minidom.parseString(r.text)
    for node in response.getElementsByTagName("s:key"):
        if node.hasAttribute("name") and node.getAttribute("name") == "dispatchState":
            dispatchState = node.firstChild.nodeValue
            print ("Search Status: ", dispatchState)
            if dispatchState == "DONE":
                done = True
            else:
                time.sleep(1)

r = requests.get(base_url + '/services/search/jobs/' + sid + '/results/',
    headers = { 'Authorization': ('Splunk %s' %session_key)},
    data={'output_mode': 'json'},
    verify = False)

pprint.pprint(json.loads(r.text))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Events returned, here is one entry sample, all events i am searching seem to get returned but not sure what's causing the _raw event error.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;{'_bkt': 'main~18~95A72A43-AF2F-49CF-B85A-B0788E1AA28A',
              '_cd': '18:455',
              '_indextime': '1632029978',
              '_raw': 'Server: DC-C02SD43JG8WP, Error: Unable to run data '
                      'collection. Error: Password prompt encountered. '
                      'Aborting.',
              '_serial': '38',
              '_si': ['DC-C02SD43JG8WP', 'main'],
              '_sourcetype': 'ossec_agent_control',
              '_time': '2021-09-18T23:39:38.000-06:00',
              'host': 'DC-C02SD43JG8WP',
              'index': 'main',
              'linecount': '1',
              'source': 'ossec_agent_control',
              'sourcetype': 'ossec_agent_control',
              'splunk_server': 'DC-C02SD43JG8WP'},&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 02:02:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Rest-api-error-on-get-raw-events/m-p/567568#M10085</guid>
      <dc:creator>sonicZ</dc:creator>
      <dc:date>2021-09-20T02:02:45Z</dc:date>
    </item>
    <item>
      <title>Re: Rest api error on get _raw events</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Rest-api-error-on-get-raw-events/m-p/567582#M10086</link>
      <description>&lt;P&gt;But what's the problem? It seems you're getting your events. It's not a splunk error, it's an error being the contents of an event (in this case - coming from ossec). Or am I missing something?&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 05:16:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Rest-api-error-on-get-raw-events/m-p/567582#M10086</guid>
      <dc:creator>PickleRick</dc:creator>
      <dc:date>2021-09-20T05:16:31Z</dc:date>
    </item>
    <item>
      <title>Re: Rest api error on get _raw events</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Rest-api-error-on-get-raw-events/m-p/567664#M10087</link>
      <description>&lt;P&gt;your right PickleRick, i&amp;nbsp; indexed in a bunch of other data as well.&lt;/P&gt;&lt;P&gt;should have paid attention to my actual event test data, assumed the error was something from the api script run, woops! just not familiar with the actual output yet.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Sep 2021 13:23:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Rest-api-error-on-get-raw-events/m-p/567664#M10087</guid>
      <dc:creator>sonicZ</dc:creator>
      <dc:date>2021-09-20T13:23:49Z</dc:date>
    </item>
  </channel>
</rss>

