<?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: Splunk - Rest API - Curl - Failing with Unbalanced Quotes in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-Rest-API-Curl-Failing-with-Unbalanced-Quotes/m-p/680639#M113709</link>
    <description>&lt;P&gt;This is working when we query directly from Splunk Search..&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| stats count as field1 | eval field1="dallvcflwb110u,yes;dallvcflwb120u,yes" | eval field1=split(field1,";") | mvexpand field1 | rex field=field1 "(?&amp;lt;host&amp;gt;.*),(?&amp;lt;mode&amp;gt;.*)" | table host mode | outputlookup atlassian_maintenance.csv&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But when we try hitting using curl and its failing .&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;curl -k -u admin:Vzadmin@12 https://dallpsplsh01sp.tpd-soe.net:8089/servicesNS/admin/SRE/search/jobs/export -d search="| stats count as field1 | eval field1="dallvcflwb110u,yes;dallvcflwb120u,yes" | eval field1=split(field1,";") | mvexpand field1 | rex field=field1 "(?&amp;lt;host&amp;gt;.*),(?&amp;lt;mode&amp;gt;.*)" | table host mode | outputlookup atlassian_maintenance.csv"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-bash: syntax error near unexpected token `?'&lt;/P&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;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 14 Mar 2024 10:57:34 GMT</pubDate>
    <dc:creator>Maries</dc:creator>
    <dc:date>2024-03-14T10:57:34Z</dc:date>
    <item>
      <title>Splunk - Rest API - Curl - Failing with Unbalanced Quotes</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-Rest-API-Curl-Failing-with-Unbalanced-Quotes/m-p/680630#M113707</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to write data to outputlookup file by doing a REST API Call (by running a search query).&lt;/P&gt;&lt;P&gt;The below command works and writes data to outputlookup csv file when running the search directly from Splunk.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;| stats count as field1 | eval field1="host_abc;host_def" | eval field1=split(field1,";") | mvexpand field1 | rex field=field1 "(?&amp;lt;host&amp;gt;.*)" | table host | outputlookup test_maintenance.csv&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;But this is not working when executing the above search using REST API.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Getting the below error "Unbalanced quotes" when running the below command&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;curl -k -u admin:admin &lt;A href="https://splunksearchnode:8089/servicesNS/admin/search/jobs/export" target="_blank" rel="noopener"&gt;https://splunksearchnode:8089/servicesNS/admin/search/jobs/export&lt;/A&gt; -d search="| stats count as field1 | eval field1=\"host_abc;host_def\" | eval field1=split(field1,\";\") | mvexpand field1 | rex field=field1 \"(?&amp;lt;host&amp;gt;.*)\" | table host | outputlookup test_maintenance.csv"&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Getting the below error&amp;nbsp; when running the below command&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Error :&amp;nbsp;Error in 'EvalCommand': The expression is malformed. An unexpected character is reached at '\'host_abc'.&amp;lt;/msg&amp;gt;&amp;lt;/messages&amp;gt;&amp;lt;/response&amp;gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;curl -k -u admin:admin &lt;A href="https://splunksearchnode:8089/servicesNS/admin/search/jobs/export" target="_blank" rel="noopener"&gt;https://splunksearchnode:8089/servicesNS/admin/search/jobs/export&lt;/A&gt; -d search='| stats count as field1 | eval field1=\"host_abc;host_def\" | eval field1=split(field1,\";\") | mvexpand field1 | rex field=field1 \"(?&amp;lt;host&amp;gt;.*)\" | table host | outputlookup test_maintenance.csv'&lt;/P&gt;&lt;P&gt;Appreciate your help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2024 04:02:15 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-Rest-API-Curl-Failing-with-Unbalanced-Quotes/m-p/680630#M113707</guid>
      <dc:creator>Maries</dc:creator>
      <dc:date>2024-03-14T04:02:15Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk - Rest API - Curl - Failing with Unbalanced Quotes</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-Rest-API-Curl-Failing-with-Unbalanced-Quotes/m-p/680635#M113708</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;can you please remove the "\" and give a try&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Karthi_0-1710396893621.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/29742iDE18B30A28056DD0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Karthi_0-1710396893621.png" alt="Karthi_0-1710396893621.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2024 06:15:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-Rest-API-Curl-Failing-with-Unbalanced-Quotes/m-p/680635#M113708</guid>
      <dc:creator>Karthi</dc:creator>
      <dc:date>2024-03-14T06:15:25Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk - Rest API - Curl - Failing with Unbalanced Quotes</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-Rest-API-Curl-Failing-with-Unbalanced-Quotes/m-p/680639#M113709</link>
      <description>&lt;P&gt;This is working when we query directly from Splunk Search..&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;| stats count as field1 | eval field1="dallvcflwb110u,yes;dallvcflwb120u,yes" | eval field1=split(field1,";") | mvexpand field1 | rex field=field1 "(?&amp;lt;host&amp;gt;.*),(?&amp;lt;mode&amp;gt;.*)" | table host mode | outputlookup atlassian_maintenance.csv&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;But when we try hitting using curl and its failing .&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;curl -k -u admin:Vzadmin@12 https://dallpsplsh01sp.tpd-soe.net:8089/servicesNS/admin/SRE/search/jobs/export -d search="| stats count as field1 | eval field1="dallvcflwb110u,yes;dallvcflwb120u,yes" | eval field1=split(field1,";") | mvexpand field1 | rex field=field1 "(?&amp;lt;host&amp;gt;.*),(?&amp;lt;mode&amp;gt;.*)" | table host mode | outputlookup atlassian_maintenance.csv"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;-bash: syntax error near unexpected token `?'&lt;/P&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2024 10:57:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-Rest-API-Curl-Failing-with-Unbalanced-Quotes/m-p/680639#M113709</guid>
      <dc:creator>Maries</dc:creator>
      <dc:date>2024-03-14T10:57:34Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk - Rest API - Curl - Failing with Unbalanced Quotes</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-Rest-API-Curl-Failing-with-Unbalanced-Quotes/m-p/680645#M113710</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;please don't add your admin user + it's pass to any posts. Or actually write those on cmd as those are stored into history files and/or are seen on process list! Much better way is to read those into variable and then use that on queries. You could do it like&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;read USERPASS
admin:&amp;lt;your pass here&amp;gt;
^D
curl -ku $USERPASS .....&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also don't add your real node name into examples!&lt;/P&gt;&lt;P&gt;As you are in linux/*nix you could replace those outer " with ' and then it should work. Then you are not needs \" inside your SPL.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;curl -ku $USERPASS https://&amp;lt;your splunk SH&amp;gt;:&amp;lt;mgmt port&amp;gt;/servicesNS/admin/SRE/search/jobs/export -d search='| stats count as field1 | eval field1="dallvcflwb110u,yes;dallvcflwb120u,yes" | eval field1=split(field1,";") | mvexpand field1 | rex field=field1 "(?&amp;lt;host&amp;gt;.*),(?&amp;lt;mode&amp;gt;.*)" | table host mode | outputlookup atlassian_maintenance.csv'&lt;/LI-CODE&gt;&lt;P&gt;In windows this didn't work ;-(&lt;/P&gt;&lt;P&gt;r. Ismo&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Mar 2024 07:41:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-Rest-API-Curl-Failing-with-Unbalanced-Quotes/m-p/680645#M113710</guid>
      <dc:creator>isoutamo</dc:creator>
      <dc:date>2024-03-14T07:41:55Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk - Rest API - Curl - Failing with Unbalanced Quotes</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-Rest-API-Curl-Failing-with-Unbalanced-Quotes/m-p/680648#M113712</link>
      <description>&lt;P&gt;Hi Maries,&lt;/P&gt;
&lt;P&gt;Please try with the below search&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;&amp;lt;your curl command&amp;gt; -d search= "search index=&amp;lt;indexname&amp;gt; | stats count as field1 | eval field1="dallvcflwb110u,yes;dallvcflwb120u,yes" | eval field1=split(field1,";") | mvexpand field1 | rex field=field1 \"(?&amp;lt;host&amp;gt;.*),(?&amp;lt;mode&amp;gt;.*)\" | table host mode | outputlookup atlassian_maintenance.csv"&lt;/LI-CODE&gt;</description>
      <pubDate>Thu, 14 Mar 2024 10:58:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-Rest-API-Curl-Failing-with-Unbalanced-Quotes/m-p/680648#M113712</guid>
      <dc:creator>kartm2020</dc:creator>
      <dc:date>2024-03-14T10:58:30Z</dc:date>
    </item>
  </channel>
</rss>

