<?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: Query doesn't work under CURL call (but is fine under user interface) in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/Query-doesn-t-work-under-CURL-call-but-is-fine-under-user/m-p/353816#M104726</link>
    <description>&lt;P&gt;It might help to post the real query, because so far there are only snippets of it. Also it would be good to tell what did not work with the &lt;CODE&gt;--data-urlencode&lt;/CODE&gt;.&lt;/P&gt;</description>
    <pubDate>Thu, 15 Mar 2018 00:23:48 GMT</pubDate>
    <dc:creator>MuS</dc:creator>
    <dc:date>2018-03-15T00:23:48Z</dc:date>
    <item>
      <title>Query doesn't work under CURL call (but is fine under user interface)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-doesn-t-work-under-CURL-call-but-is-fine-under-user/m-p/353812#M104722</link>
      <description>&lt;P&gt;Hi; I have a query that ends as follows&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;| stats count(eval(HttpStatus LIKE "2__")) AS success 
count(eval(HttpStatus LIKE "5__")) AS fail 
count as total by host
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;And under the Splunk UI environment I get my results as desired.&lt;BR /&gt;
But the issue I see is when I use the exact same query under the Splunk CLI/CURL call to the service, i get the following response&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;{'messages': [{'type': 'FATAL', 'text': "Error in 'stats' command: The eval expression for dynamic field 'eval(HttpStatus LIKE 2__)' is invalid. Error='The operator at '__' is invalid.'"}]}
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I've tried different variations of encapsulating the "httpstatus" field but non of them were successful (tried escaping characters also)&lt;/P&gt;

&lt;P&gt;Please advise in solving this issue&lt;BR /&gt;
Much appreciated&lt;/P&gt;

&lt;UL&gt;
&lt;LI&gt;Randy&lt;/LI&gt;
&lt;/UL&gt;</description>
      <pubDate>Wed, 14 Mar 2018 22:30:31 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-doesn-t-work-under-CURL-call-but-is-fine-under-user/m-p/353812#M104722</guid>
      <dc:creator>h0riz0nhk</dc:creator>
      <dc:date>2018-03-14T22:30:31Z</dc:date>
    </item>
    <item>
      <title>Re: Query doesn't work under CURL call (but is fine under user interface)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-doesn-t-work-under-CURL-call-but-is-fine-under-user/m-p/353813#M104723</link>
      <description>&lt;P&gt;Hi h0riz0nhk,&lt;/P&gt;

&lt;P&gt;this works just fine for me:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;curl -k -u user:password &lt;A href="https://hostname:8089/services/search/jobs/export" target="test_blank"&gt;https://hostname:8089/services/search/jobs/export&lt;/A&gt; --data-urlencode 'search=search index="_internal" | stats count(eval(sourcetype LIKE "splunk%")) AS st_splunk count AS total by host ' -d output_mode=csv
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;and the result is this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;host,"st_splunk",total
hostname,308212,310456
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;the important thing here is to use &lt;CODE&gt;--data-urlencode&lt;/CODE&gt; otherwise it will fail because of the &lt;CODE&gt;"&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;Hope this helps ...&lt;/P&gt;

&lt;P&gt;cheers, MuS&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 23:00:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-doesn-t-work-under-CURL-call-but-is-fine-under-user/m-p/353813#M104723</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2018-03-14T23:00:21Z</dc:date>
    </item>
    <item>
      <title>Re: Query doesn't work under CURL call (but is fine under user interface)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-doesn-t-work-under-CURL-call-but-is-fine-under-user/m-p/353814#M104724</link>
      <description>&lt;P&gt;Sadly the &lt;CODE&gt;--data-urlencode&lt;/CODE&gt; didn't work for me, but finally found a solution&lt;/P&gt;

&lt;P&gt;Essentially i had a query builder and had to encapsulate the &lt;CODE&gt;search=\'' + search query +'\'&lt;/CODE&gt; correctly&lt;BR /&gt;
(was being lazy with &lt;CODE&gt;search="' + search query +'"&lt;/CODE&gt;)&lt;/P&gt;</description>
      <pubDate>Wed, 14 Mar 2018 23:59:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-doesn-t-work-under-CURL-call-but-is-fine-under-user/m-p/353814#M104724</guid>
      <dc:creator>h0riz0nhk</dc:creator>
      <dc:date>2018-03-14T23:59:23Z</dc:date>
    </item>
    <item>
      <title>Re: Query doesn't work under CURL call (but is fine under user interface)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-doesn-t-work-under-CURL-call-but-is-fine-under-user/m-p/353815#M104725</link>
      <description>&lt;P&gt;Fixed by changing the encapsulate part of my function to not be lazy&lt;BR /&gt;
&lt;CODE&gt;search="' + search_query + '"&lt;/CODE&gt;&lt;BR /&gt;
to&lt;BR /&gt;
&lt;CODE&gt;search=\'' + search_query + '\'&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2018 00:01:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-doesn-t-work-under-CURL-call-but-is-fine-under-user/m-p/353815#M104725</guid>
      <dc:creator>h0riz0nhk</dc:creator>
      <dc:date>2018-03-15T00:01:08Z</dc:date>
    </item>
    <item>
      <title>Re: Query doesn't work under CURL call (but is fine under user interface)</title>
      <link>https://community.splunk.com/t5/Splunk-Search/Query-doesn-t-work-under-CURL-call-but-is-fine-under-user/m-p/353816#M104726</link>
      <description>&lt;P&gt;It might help to post the real query, because so far there are only snippets of it. Also it would be good to tell what did not work with the &lt;CODE&gt;--data-urlencode&lt;/CODE&gt;.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Mar 2018 00:23:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/Query-doesn-t-work-under-CURL-call-but-is-fine-under-user/m-p/353816#M104726</guid>
      <dc:creator>MuS</dc:creator>
      <dc:date>2018-03-15T00:23:48Z</dc:date>
    </item>
  </channel>
</rss>

