<?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: Problems using the REST API to search in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Problems-using-the-REST-API-to-search/m-p/58236#M11427</link>
    <description>&lt;P&gt;Thanks, I'll check it out.&lt;/P&gt;</description>
    <pubDate>Wed, 25 Jan 2012 23:05:53 GMT</pubDate>
    <dc:creator>merritsa</dc:creator>
    <dc:date>2012-01-25T23:05:53Z</dc:date>
    <item>
      <title>Problems using the REST API to search</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Problems-using-the-REST-API-to-search/m-p/58231#M11422</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;

&lt;P&gt;I have several questions/issues with the Splunk API, so I'll try to keep this short and concise.&lt;/P&gt;

&lt;P&gt;First - does splunk offer a WSDL?  That would really solve all this for me.  If not, then here's my next question of many:&lt;/P&gt;

&lt;P&gt;What's causing this error?&lt;/P&gt;

&lt;P&gt;&lt;ITEM&gt;Error in 'search' command: Unable to parse the search: Comparator '=' is missing a term on the left hand side.&lt;A href="https://answers.splunk.coms:item"&gt;/s:item&lt;/A&gt;&lt;/ITEM&gt;&lt;/P&gt;

&lt;P&gt;I get that when I attempt to call the Splunk API with an HP OO HTTP Client GET operation.&lt;/P&gt;

&lt;P&gt;I have ideas for workarounds (including using WMI to run splunk CLI search commands and getting results) but they have their own issues.  I'd like to tackle this one first.&lt;/P&gt;

&lt;P&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2012 21:18:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Problems-using-the-REST-API-to-search/m-p/58231#M11422</guid>
      <dc:creator>merritsa</dc:creator>
      <dc:date>2012-01-25T21:18:43Z</dc:date>
    </item>
    <item>
      <title>Re: Problems using the REST API to search</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Problems-using-the-REST-API-to-search/m-p/58232#M11423</link>
      <description>&lt;P&gt;Maybe it would help if you post your search string to check the syntax. &lt;span class="lia-unicode-emoji" title=":winking_face:"&gt;😉&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2012 21:32:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Problems-using-the-REST-API-to-search/m-p/58232#M11423</guid>
      <dc:creator>jensihnow</dc:creator>
      <dc:date>2012-01-25T21:32:27Z</dc:date>
    </item>
    <item>
      <title>Re: Problems using the REST API to search</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Problems-using-the-REST-API-to-search/m-p/58233#M11424</link>
      <description>&lt;P&gt;Of course, my apologies &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;  I'm on a conference call and replying to both IM and email too...I'm a terrible multi-tasker.&lt;/P&gt;

&lt;P&gt;Here you go...&lt;/P&gt;

&lt;P&gt;Post from the HTTP Client POST operation in OO:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://&amp;lt;splunk_server/services/search/jobs/" target="test_blank"&gt;https://&amp;lt;splunk_server/services/search/jobs/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;search=cdp * | head 10,output_mode=xml&lt;/P&gt;

&lt;P&gt;inputValueSet&lt;BR /&gt;
search=cdp * | head 10,output_mode=xml&lt;/P&gt;

&lt;P&gt;inputNameList&lt;BR /&gt;
search,output&lt;/P&gt;

&lt;P&gt;delimeter&lt;BR /&gt;
,&lt;/P&gt;

&lt;P&gt;This returns success and gives me what looks to be an epoch time as a result.  I've read that this is the name of the splunk search results (in this case, 1327527878.25639.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2012 21:52:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Problems-using-the-REST-API-to-search/m-p/58233#M11424</guid>
      <dc:creator>merritsa</dc:creator>
      <dc:date>2012-01-25T21:52:21Z</dc:date>
    </item>
    <item>
      <title>Re: Problems using the REST API to search</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Problems-using-the-REST-API-to-search/m-p/58234#M11425</link>
      <description>&lt;P&gt;So then I run an HTTP Client GET to get those results, at which point I get the error I originally posted - &lt;ITEM&gt;Error in 'search' command: Unable to parse the search: Comparator '=' is missing a term on the left hand side.&lt;A href="https://answers.splunk.coms:item"&gt;/s:item&lt;/A&gt;.&lt;/ITEM&gt;&lt;/P&gt;

&lt;P&gt;It's down in the middle of all the xml output I get as a reply.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2012 21:52:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Problems-using-the-REST-API-to-search/m-p/58234#M11425</guid>
      <dc:creator>merritsa</dc:creator>
      <dc:date>2012-01-25T21:52:25Z</dc:date>
    </item>
    <item>
      <title>Re: Problems using the REST API to search</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Problems-using-the-REST-API-to-search/m-p/58235#M11426</link>
      <description>&lt;P&gt;Not a WSDL , but an endpoint reference can be found here :&lt;/P&gt;

&lt;P&gt;&lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI/RESTlist"&gt;http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI/RESTlist&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2012 22:07:54 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Problems-using-the-REST-API-to-search/m-p/58235#M11426</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2012-01-25T22:07:54Z</dc:date>
    </item>
    <item>
      <title>Re: Problems using the REST API to search</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Problems-using-the-REST-API-to-search/m-p/58236#M11427</link>
      <description>&lt;P&gt;Thanks, I'll check it out.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Jan 2012 23:05:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Problems-using-the-REST-API-to-search/m-p/58236#M11427</guid>
      <dc:creator>merritsa</dc:creator>
      <dc:date>2012-01-25T23:05:53Z</dc:date>
    </item>
    <item>
      <title>Re: Problems using the REST API to search</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Problems-using-the-REST-API-to-search/m-p/58237#M11428</link>
      <description>&lt;P&gt;You created a search job and got a jobid. But if you are going to get the results you got the splunk error. That looks like your search is not send correct to splunk by the request. At &lt;A href="http://dev.splunk.com/view/basic-tutorial/SP-CAAADQT"&gt;http://dev.splunk.com/view/basic-tutorial/SP-CAAADQT&lt;/A&gt; is a nice tutorial with some examples:&lt;BR /&gt;
curl -k -u admin:changeme -d 'search="search error"' &lt;A href="https://localhost:8089/servicesNS/admin/search/search/jobs"&gt;https://localhost:8089/servicesNS/admin/search/search/jobs&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Maybe the quoting/encoding of your request is wrong.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2012 08:16:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Problems-using-the-REST-API-to-search/m-p/58237#M11428</guid>
      <dc:creator>jensihnow</dc:creator>
      <dc:date>2012-01-26T08:16:17Z</dc:date>
    </item>
    <item>
      <title>Re: Problems using the REST API to search</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Problems-using-the-REST-API-to-search/m-p/58238#M11429</link>
      <description>&lt;P&gt;So based on that reference page, as far as I can tell, it's formatted correctly.  What's the next step to ts this?&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2012 15:13:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Problems-using-the-REST-API-to-search/m-p/58238#M11429</guid>
      <dc:creator>merritsa</dc:creator>
      <dc:date>2012-01-26T15:13:52Z</dc:date>
    </item>
    <item>
      <title>Re: Problems using the REST API to search</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Problems-using-the-REST-API-to-search/m-p/58239#M11430</link>
      <description>&lt;P&gt;Exactly.  Splunk never returns an error on the search itself when I post it.  &lt;/P&gt;

&lt;P&gt;I'll play with it some more and report back.  Thanks.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Jan 2012 15:15:06 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Problems-using-the-REST-API-to-search/m-p/58239#M11430</guid>
      <dc:creator>merritsa</dc:creator>
      <dc:date>2012-01-26T15:15:06Z</dc:date>
    </item>
    <item>
      <title>Re: Problems using the REST API to search</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Problems-using-the-REST-API-to-search/m-p/58240#M11431</link>
      <description>&lt;P&gt;I would suggest to modify the "search" parameter in your POST request to :&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;search=search cdp * | head 10&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;...instead of :&lt;/P&gt;

&lt;P&gt;&lt;CODE&gt;search=cdp * | head 10&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;...as specified in the &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI/RESTsearch#POST_search.2Fjobs"&gt;REST API reference for the search/jobs endpoint&lt;/A&gt;:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Name    Type    Required    Default     Description
search  String  ✓                     The search language string to execute, taking results from the local and remote servers.

Examples:
    "search *" 
    "search * | outputcsv" 
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(...)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;The search string for the search parameter must be prefixed with "search." Thus, it is in the form:

search search_string
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;(...)&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;curl -k -u admin:pass &lt;A href="https://localhost:8089/servicesNS/admin/search/search/jobs" target="test_blank"&gt;https://localhost:8089/servicesNS/admin/search/search/jobs&lt;/A&gt; \
    --data-urlencode search="search index=_internal source=*/metrics.log" \
    -d id=mysearch_02151949 \
    -d max_count=50000 \
    -d status_buckets=300&amp;lt;/code&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The error you are seeing is shown because your search string is the equivalent of typing "&lt;CODE&gt;=cdp * | head 10&lt;/CODE&gt;" in the Splunkweb search bar, which would indeed have a missing term on the left side of an "=" operand.&lt;/P&gt;

&lt;P&gt;This is because the Splunkweb search bar silently appends the search terms you provide to the &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/SearchReference/Search"&gt;search&lt;/A&gt; commmand, which results in a separate "splunk search" process.&lt;/P&gt;

&lt;P&gt;If you compare a search job entry from a Splunkweb ad-hoc search @ &lt;CODE&gt;&lt;A href="https://localhost:8089/services/search/jobs/"&gt;https://localhost:8089/services/search/jobs/&lt;/A&gt;&lt;SID&gt;&lt;/SID&gt;&lt;/CODE&gt; with the one generated by your search, you'll see the difference.&lt;/P&gt;

&lt;P&gt;Essentially, you'll want to modify your POST request so that the name of the job object you create @ &lt;CODE&gt;&lt;A href="https://localhost:8089/services/search/jobs/"&gt;https://localhost:8089/services/search/jobs/&lt;/A&gt;&lt;SID&gt;&lt;/SID&gt;&lt;/CODE&gt; is "&lt;CODE&gt;search cdp * | head 10&lt;/CODE&gt;" and not "&lt;CODE&gt;search=cdp * | head 10&lt;/CODE&gt;".&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jan 2012 07:15:17 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Problems-using-the-REST-API-to-search/m-p/58240#M11431</guid>
      <dc:creator>hexx</dc:creator>
      <dc:date>2012-01-27T07:15:17Z</dc:date>
    </item>
    <item>
      <title>Re: Problems using the REST API to search</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Problems-using-the-REST-API-to-search/m-p/58241#M11432</link>
      <description>&lt;P&gt;@merritsa: Thank you for accepting my answer. Did my instructions resolve your problem?&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jan 2012 20:28:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Problems-using-the-REST-API-to-search/m-p/58241#M11432</guid>
      <dc:creator>hexx</dc:creator>
      <dc:date>2012-01-27T20:28:25Z</dc:date>
    </item>
    <item>
      <title>Re: Problems using the REST API to search</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Problems-using-the-REST-API-to-search/m-p/58242#M11433</link>
      <description>&lt;P&gt;Thanks, this got me a lot closer.  I revised the command to instead be search cdp * | head 10,output_mode=xml, since the command "search" seems to be accounted for elsewhere in the post operation input.  &lt;/P&gt;

&lt;P&gt;Though I still don't seem to have results.  Just a lack of an error message.  In looking through it, it seems this might be why:&lt;/P&gt;

&lt;P&gt;&lt;KEY name="cursorTime"&gt;1969-12-31T16:00:00.000-08:00&lt;A href="https://answers.splunk.coms:key"&gt;/s:key&lt;/A&gt;&lt;/KEY&gt;&lt;/P&gt;

&lt;P&gt;I'll try to figure out how to denote a proper search time.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jan 2012 20:29:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Problems-using-the-REST-API-to-search/m-p/58242#M11433</guid>
      <dc:creator>merritsa</dc:creator>
      <dc:date>2012-01-27T20:29:34Z</dc:date>
    </item>
    <item>
      <title>Re: Problems using the REST API to search</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Problems-using-the-REST-API-to-search/m-p/58243#M11434</link>
      <description>&lt;P&gt;You need to pass the "earliest_time" and "latest_time" parameters in your POST request to do so, just like you did for "search". You can find the specifications of these parameters in the "Request" table of the &lt;A href="http://docs.splunk.com/Documentation/Splunk/latest/RESTAPI/RESTsearch#POST_search.2Fjobs" target="_blank"&gt;REST API reference documentation&lt;/A&gt; I linked earlier.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 10:22:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Problems-using-the-REST-API-to-search/m-p/58243#M11434</guid>
      <dc:creator>hexx</dc:creator>
      <dc:date>2020-09-28T10:22:18Z</dc:date>
    </item>
  </channel>
</rss>

