<?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: Why can't I delete kvstore collections using the REST API via Python? in Splunk Dev</title>
    <link>https://community.splunk.com/t5/Splunk-Dev/Why-can-t-I-delete-kvstore-collections-using-the-REST-API-via/m-p/121361#M1751</link>
    <description>&lt;P&gt;I cannot delete either. I get an error:&lt;/P&gt;

&lt;P&gt;curl -k -s -u admin:changeme  &lt;A href="https://localhost:8089/servicesNS/nobody/myapp/storage/collections/config/test_collection_collection"&gt;https://localhost:8089/servicesNS/nobody/myapp/storage/collections/config/test_collection_collection&lt;/A&gt;  -X DELETE&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;msg type="ERROR"&amp;gt;Object id=test_collection_collection cannot be deleted in config=collections.&amp;lt;/msg&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
    <pubDate>Wed, 01 Feb 2017 15:06:53 GMT</pubDate>
    <dc:creator>dsmc_adv</dc:creator>
    <dc:date>2017-02-01T15:06:53Z</dc:date>
    <item>
      <title>Why can't I delete kvstore collections using the REST API via Python?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Why-can-t-I-delete-kvstore-collections-using-the-REST-API-via/m-p/121358#M1748</link>
      <description>&lt;P&gt;I'm trying to delete kvstore collection using REST API via Python:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;url = "https://localhost:8089/servicesNS/nobody/myapp/storage/collections/config/deleteme"
request = urllib2.Request(url, headers = {"Authorization" : "Splunk "})
request.get_method = lambda: "DELETE"
results = urllib2.urlopen(request)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This returns &lt;CODE&gt;HTTP Error 400: Bad request.&lt;/CODE&gt;&lt;/P&gt;

&lt;P&gt;The code works for other kvstore functions (when changing the URL) such as deleting collection's &lt;EM&gt;data&lt;/EM&gt;, and I used the correct URL according to the &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.2.2/RESTREF/RESTkvstore#storage.2Fcollections.2Fconfig.2F.7Bcollection.7D"&gt;documentation&lt;/A&gt; so I can't figure out why this doesn't work.&lt;/P&gt;</description>
      <pubDate>Thu, 02 Apr 2015 10:19:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Why-can-t-I-delete-kvstore-collections-using-the-REST-API-via/m-p/121358#M1748</guid>
      <dc:creator>pembleton</dc:creator>
      <dc:date>2015-04-02T10:19:05Z</dc:date>
    </item>
    <item>
      <title>Re: Why can't I delete kvstore collections using the REST API via Python?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Why-can-t-I-delete-kvstore-collections-using-the-REST-API-via/m-p/121359#M1749</link>
      <description>&lt;P&gt;What happens if you make the same request using curl? Also, likely there is some output together with the 400 status code - can you post it here?&lt;/P&gt;</description>
      <pubDate>Thu, 02 Apr 2015 18:29:48 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Why-can-t-I-delete-kvstore-collections-using-the-REST-API-via/m-p/121359#M1749</guid>
      <dc:creator>ineeman</dc:creator>
      <dc:date>2015-04-02T18:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: Why can't I delete kvstore collections using the REST API via Python?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Why-can-t-I-delete-kvstore-collections-using-the-REST-API-via/m-p/121360#M1750</link>
      <description>&lt;P&gt;i found this frustrating too.  you actually have to &lt;CODE&gt;POST&lt;/CODE&gt; the option as shown in the CURL examples in the docs.&lt;/P&gt;

&lt;P&gt;the way i do it is using splunk's rest.simpleRequest method.  strangely, i always seem to misplace the link for the SDK, but here's an example:&lt;BR /&gt;
&lt;A href="http://answers.splunk.com/answers/144000/modifying-acl-saved-search-permissions-through-rest-api-using-python.html"&gt;http://answers.splunk.com/answers/144000/modifying-acl-saved-search-permissions-through-rest-api-using-python.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;it's not ideal - but perhaps you could first retrieve all the data points in that collection, and then iteratively delete them?&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;query_uri = '/servicesNS/nobody/&amp;lt;app&amp;gt;/storage/collections/data/&amp;lt;kvstore&amp;gt;'
serverResponse, serverContent = rest.simpleRequest(query_uri, sessionKey=sessionKey)
for result in serverContent:
removal_uri = '/servicesNS/nobody/&amp;lt;app&amp;gt;/storage/collections/data/&amp;lt;kvstore&amp;gt;/%s' % result['_key']
    serverResponse, serverContent = rest.simpleRequest(removal_uri, sessionKey=sessionKey, method='DELETE')
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;maybe you can also leverage one of the answers from my similar question:&lt;BR /&gt;
&lt;A href="https://answers.splunk.com/answers/237859/can-i-delete-all-data-from-a-kv-store-at-once.html"&gt;https://answers.splunk.com/answers/237859/can-i-delete-all-data-from-a-kv-store-at-once.html&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jun 2015 04:14:28 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Why-can-t-I-delete-kvstore-collections-using-the-REST-API-via/m-p/121360#M1750</guid>
      <dc:creator>awurster</dc:creator>
      <dc:date>2015-06-12T04:14:28Z</dc:date>
    </item>
    <item>
      <title>Re: Why can't I delete kvstore collections using the REST API via Python?</title>
      <link>https://community.splunk.com/t5/Splunk-Dev/Why-can-t-I-delete-kvstore-collections-using-the-REST-API-via/m-p/121361#M1751</link>
      <description>&lt;P&gt;I cannot delete either. I get an error:&lt;/P&gt;

&lt;P&gt;curl -k -s -u admin:changeme  &lt;A href="https://localhost:8089/servicesNS/nobody/myapp/storage/collections/config/test_collection_collection"&gt;https://localhost:8089/servicesNS/nobody/myapp/storage/collections/config/test_collection_collection&lt;/A&gt;  -X DELETE&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&amp;lt;msg type="ERROR"&amp;gt;Object id=test_collection_collection cannot be deleted in config=collections.&amp;lt;/msg&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 01 Feb 2017 15:06:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Dev/Why-can-t-I-delete-kvstore-collections-using-the-REST-API-via/m-p/121361#M1751</guid>
      <dc:creator>dsmc_adv</dc:creator>
      <dc:date>2017-02-01T15:06:53Z</dc:date>
    </item>
  </channel>
</rss>

