<?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 Splunk Python API example not encoding URL properly in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-Python-API-example-not-encoding-URL-properly/m-p/183656#M2444</link>
    <description>&lt;P&gt;I'm trying to work with the lastest Splunk Python SDK, version 1.3.0 I believe, using Python 2.6.6. Our Splunk server is 6.1.5. Working through the examples provided, I was unable to use examples/saved_search/saved_search.py to list out the details of a specific saved search.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[user@web saved_search]$ ./saved_search.py list --name="SLB server disabled"
Traceback (most recent call last):
  File "./saved_search.py", line 216, in &amp;lt;module&amp;gt;
    main(sys.argv[1:])
  File "./saved_search.py", line 206, in main
    result = context.get("saved/searches/%s" % name, **kwargs)
  File "./../../splunklib/binding.py", line 240, in wrapper
    return request_fun(self, *args, **kwargs)
  File "./../../splunklib/binding.py", line 62, in new_f
    val = f(*args, **kwargs)
  File "./../../splunklib/binding.py", line 585, in get
    response = self.http.get(path, self._auth_headers, **query)
  File "./../../splunklib/binding.py", line 1055, in get
    return self.request(url, { 'method': "GET", 'headers': headers })
  File "./../../splunklib/binding.py", line 1110, in request
    raise HTTPError(response)
splunklib.binding.HTTPError: HTTP 404 Not Found --
 In handler 'savedsearch': Could not find object id=SLB%20server%20disabled
[user@web saved_search]$
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, if I take a look at the URL for that search in Splunk, I see that the encoding is different.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;https://web:8000/en-US/app/search/alert?s=%2FservicesNS%2Fnobody%2Fsearch%2Fsaved%2Fsearches%2FSLB%2520server%2520disabled
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Anyone know what might be going on here? I've set my version=6.1 in my ~/.splunkrc file. Other examples seem to work ok.&lt;/P&gt;

&lt;P&gt;Thanks, Jay&lt;/P&gt;</description>
    <pubDate>Mon, 28 Sep 2020 18:37:52 GMT</pubDate>
    <dc:creator>titleistfour</dc:creator>
    <dc:date>2020-09-28T18:37:52Z</dc:date>
    <item>
      <title>Splunk Python API example not encoding URL properly</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-Python-API-example-not-encoding-URL-properly/m-p/183656#M2444</link>
      <description>&lt;P&gt;I'm trying to work with the lastest Splunk Python SDK, version 1.3.0 I believe, using Python 2.6.6. Our Splunk server is 6.1.5. Working through the examples provided, I was unable to use examples/saved_search/saved_search.py to list out the details of a specific saved search.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[user@web saved_search]$ ./saved_search.py list --name="SLB server disabled"
Traceback (most recent call last):
  File "./saved_search.py", line 216, in &amp;lt;module&amp;gt;
    main(sys.argv[1:])
  File "./saved_search.py", line 206, in main
    result = context.get("saved/searches/%s" % name, **kwargs)
  File "./../../splunklib/binding.py", line 240, in wrapper
    return request_fun(self, *args, **kwargs)
  File "./../../splunklib/binding.py", line 62, in new_f
    val = f(*args, **kwargs)
  File "./../../splunklib/binding.py", line 585, in get
    response = self.http.get(path, self._auth_headers, **query)
  File "./../../splunklib/binding.py", line 1055, in get
    return self.request(url, { 'method': "GET", 'headers': headers })
  File "./../../splunklib/binding.py", line 1110, in request
    raise HTTPError(response)
splunklib.binding.HTTPError: HTTP 404 Not Found --
 In handler 'savedsearch': Could not find object id=SLB%20server%20disabled
[user@web saved_search]$
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However, if I take a look at the URL for that search in Splunk, I see that the encoding is different.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;https://web:8000/en-US/app/search/alert?s=%2FservicesNS%2Fnobody%2Fsearch%2Fsaved%2Fsearches%2FSLB%2520server%2520disabled
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Anyone know what might be going on here? I've set my version=6.1 in my ~/.splunkrc file. Other examples seem to work ok.&lt;/P&gt;

&lt;P&gt;Thanks, Jay&lt;/P&gt;</description>
      <pubDate>Mon, 28 Sep 2020 18:37:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-Python-API-example-not-encoding-URL-properly/m-p/183656#M2444</guid>
      <dc:creator>titleistfour</dc:creator>
      <dc:date>2020-09-28T18:37:52Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Python API example not encoding URL properly</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Splunk-Python-API-example-not-encoding-URL-properly/m-p/183657#M2445</link>
      <description>&lt;P&gt;Looks like the issue here may be this line in 177 of saved_search.py&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;kwargs[key] = urllib.quote(opts.kwargs[key])
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Which may be encoding the saved search name in a way that this version of Splunk doesn't like. Try commenting that line out and adding this in its place&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;kwargs[key] = opts.kwargs[key]
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Sun, 01 Feb 2015 17:06:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Splunk-Python-API-example-not-encoding-URL-properly/m-p/183657#M2445</guid>
      <dc:creator>Flynt</dc:creator>
      <dc:date>2015-02-01T17:06:38Z</dc:date>
    </item>
  </channel>
</rss>

