<?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 How do you url encode a query you want to send to splunk? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-url-encode-a-query-you-want-to-send-to-splunk/m-p/39586#M7365</link>
    <description>&lt;P&gt;On the splunk dev rest api guide it says that splunk queries sent through curl must first be url encoded.&lt;/P&gt;

&lt;P&gt;&lt;A href="http://dev.splunk.com/view/SP-CAAADQT" target="_blank"&gt;http://dev.splunk.com/view/SP-CAAADQT&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Some url encoders will turn a spacebar into a %20 symbol for instance. The page then goes on to show an example of url encoding with a python built in function. Can you just use the built in curl url encode function?&lt;/P&gt;

&lt;P&gt;I have a query that uses rex in a way like this and I'm not sure how to url encode correctly. Although I need to try the query out again on another search head later today.&lt;BR /&gt;
index=index obscure=keyword  earliest=8/5/2012:0:0:0 latest=8/6/2012:0:00:0 date_hour=16 (date_minute&amp;gt;=20 AND date_minute&amp;lt;30) | rex "(?im)^(?:[^:\\n]*:){3}\\d+\\s+(?P&lt;RESPONSE&gt;[^ ]+) (?P&lt;METHOD&gt;[^ ]+)" | rex "(?i) url: (http://)?(?P&lt;OKURL&gt;[^?]+)" | search method="login" OKurl="this.url.com/means_ok" | stats count AS HIT BY date_mday&lt;/OKURL&gt;&lt;/METHOD&gt;&lt;/RESPONSE&gt;&lt;/P&gt;

&lt;P&gt;You'll notice all the weird characters. I don't think splunk likes it when I url encode the spacebar character, so I'm just wondering what characters need to be url encoded.&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 12:17:49 GMT</pubDate>
    <dc:creator>obesechicken13</dc:creator>
    <dc:date>2020-09-28T12:17:49Z</dc:date>
    <item>
      <title>How do you url encode a query you want to send to splunk?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-url-encode-a-query-you-want-to-send-to-splunk/m-p/39586#M7365</link>
      <description>&lt;P&gt;On the splunk dev rest api guide it says that splunk queries sent through curl must first be url encoded.&lt;/P&gt;

&lt;P&gt;&lt;A href="http://dev.splunk.com/view/SP-CAAADQT" target="_blank"&gt;http://dev.splunk.com/view/SP-CAAADQT&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Some url encoders will turn a spacebar into a %20 symbol for instance. The page then goes on to show an example of url encoding with a python built in function. Can you just use the built in curl url encode function?&lt;/P&gt;

&lt;P&gt;I have a query that uses rex in a way like this and I'm not sure how to url encode correctly. Although I need to try the query out again on another search head later today.&lt;BR /&gt;
index=index obscure=keyword  earliest=8/5/2012:0:0:0 latest=8/6/2012:0:00:0 date_hour=16 (date_minute&amp;gt;=20 AND date_minute&amp;lt;30) | rex "(?im)^(?:[^:\\n]*:){3}\\d+\\s+(?P&lt;RESPONSE&gt;[^ ]+) (?P&lt;METHOD&gt;[^ ]+)" | rex "(?i) url: (http://)?(?P&lt;OKURL&gt;[^?]+)" | search method="login" OKurl="this.url.com/means_ok" | stats count AS HIT BY date_mday&lt;/OKURL&gt;&lt;/METHOD&gt;&lt;/RESPONSE&gt;&lt;/P&gt;

&lt;P&gt;You'll notice all the weird characters. I don't think splunk likes it when I url encode the spacebar character, so I'm just wondering what characters need to be url encoded.&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 12:17:49 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-url-encode-a-query-you-want-to-send-to-splunk/m-p/39586#M7365</guid>
      <dc:creator>obesechicken13</dc:creator>
      <dc:date>2020-09-28T12:17:49Z</dc:date>
    </item>
    <item>
      <title>Re: How do you url encode a query you want to send to splunk?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-url-encode-a-query-you-want-to-send-to-splunk/m-p/39587#M7366</link>
      <description>&lt;P&gt;Curl should take care of encoding for you. There is an option "--data-urlencode" that should do the trick. You don't need to do anything, except escape it for your shell so it doesn't get altered before curl gets it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt; If you think you have problem with your shell messing with the data, you can try putting it into file and passing to curl with @filename option for --data-urlencode (see curl man-page). Also this &lt;A href="http://curl.haxx.se/docs/httpscripting.html"&gt;this tutorial&lt;/A&gt; can be useful.&lt;/P&gt;

&lt;P&gt;If tempted to encode your string manually (not recommended), here is &lt;A href="http://en.wikipedia.org/wiki/Percent-encoding"&gt;the spec&lt;/A&gt; what to do.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Aug 2012 05:14:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-url-encode-a-query-you-want-to-send-to-splunk/m-p/39587#M7366</guid>
      <dc:creator>kallu</dc:creator>
      <dc:date>2012-08-21T05:14:05Z</dc:date>
    </item>
  </channel>
</rss>

