<?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: KV store keys,  REST API and URL encoding forward slashes in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/KV-store-keys-REST-API-and-URL-encoding-forward-slashes/m-p/473118#M81300</link>
    <description>&lt;P&gt;The documentation --&amp;gt;&amp;gt; &lt;A href="https://docs.splunk.com/Documentation/SplunkCloud/8.0.0/RESTREF/RESTkvstore"&gt;https://docs.splunk.com/Documentation/SplunkCloud/8.0.0/RESTREF/RESTkvstore&lt;/A&gt;&lt;BR /&gt;
eludes to the CIDR being translated to Canonical style record when it is recorded in the KV Store.&lt;/P&gt;

&lt;P&gt;If that is true, the 1.1.1.1/29 record you are trying to delete would be recorded as 001.001.001.001/29 in the KV Store.&lt;/P&gt;

&lt;P&gt;Try running something like this to see how the data is formatted:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;curl -k -u admin:yourpassword \   &lt;A href="https://localhost:8089/servicesNS/nobody/kvstoretest/storage/collections/data/kvstorecoll" target="test_blank"&gt;https://localhost:8089/servicesNS/nobody/kvstoretest/storage/collections/data/kvstorecoll&lt;/A&gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The other thought I had was passing the key as data, as seen for save operations on the dev site--&amp;gt;&amp;gt; &lt;A href="https://dev.splunk.com/enterprise/docs/developapps/kvstore/usetherestapitomanagekv/"&gt;https://dev.splunk.com/enterprise/docs/developapps/kvstore/usetherestapitomanagekv/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I was thinking delete might work this way, but I don't see it documented anywhere.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; curl -k -u admin:yourpassword -X DELETE \  
 &lt;A href="https://localhost:8089//servicesNS/nobody/search/storage/collections/data/collectionName" target="test_blank"&gt;https://localhost:8089//servicesNS/nobody/search/storage/collections/data/collectionName&lt;/A&gt; \
        -H 'Content-Type: application/json' \
        -d '[{"name": "001.001.001.001/29"}]'
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
    <pubDate>Fri, 27 Dec 2019 17:50:14 GMT</pubDate>
    <dc:creator>mydog8it</dc:creator>
    <dc:date>2019-12-27T17:50:14Z</dc:date>
    <item>
      <title>KV store keys,  REST API and URL encoding forward slashes</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/KV-store-keys-REST-API-and-URL-encoding-forward-slashes/m-p/473117#M81299</link>
      <description>&lt;P&gt;I have a KV collection that uses a CIDR-style network address as the key value.    This means that delete operations have to send this &lt;BR /&gt;
forward slash in the URL.    I'm getting a 404 "Could not find object".&lt;/P&gt;

&lt;P&gt;For the key "1.1.1.1/29" I'm using this URL:&lt;/P&gt;

&lt;P&gt;/servicesNS/nobody/search/storage/collections/data/collectionName/1.1.1.1%2f29&lt;/P&gt;

&lt;P&gt;Update operations work fine (because the slash is in the POST data, not the URL?).&lt;/P&gt;

&lt;P&gt;What (other?) encoding/escaping do I need?   On a whim,  I tried doubling the forward slashes, but no dice.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Dec 2019 21:11:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/KV-store-keys-REST-API-and-URL-encoding-forward-slashes/m-p/473117#M81299</guid>
      <dc:creator>hughkelley</dc:creator>
      <dc:date>2019-12-26T21:11:20Z</dc:date>
    </item>
    <item>
      <title>Re: KV store keys,  REST API and URL encoding forward slashes</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/KV-store-keys-REST-API-and-URL-encoding-forward-slashes/m-p/473118#M81300</link>
      <description>&lt;P&gt;The documentation --&amp;gt;&amp;gt; &lt;A href="https://docs.splunk.com/Documentation/SplunkCloud/8.0.0/RESTREF/RESTkvstore"&gt;https://docs.splunk.com/Documentation/SplunkCloud/8.0.0/RESTREF/RESTkvstore&lt;/A&gt;&lt;BR /&gt;
eludes to the CIDR being translated to Canonical style record when it is recorded in the KV Store.&lt;/P&gt;

&lt;P&gt;If that is true, the 1.1.1.1/29 record you are trying to delete would be recorded as 001.001.001.001/29 in the KV Store.&lt;/P&gt;

&lt;P&gt;Try running something like this to see how the data is formatted:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;curl -k -u admin:yourpassword \   &lt;A href="https://localhost:8089/servicesNS/nobody/kvstoretest/storage/collections/data/kvstorecoll" target="test_blank"&gt;https://localhost:8089/servicesNS/nobody/kvstoretest/storage/collections/data/kvstorecoll&lt;/A&gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The other thought I had was passing the key as data, as seen for save operations on the dev site--&amp;gt;&amp;gt; &lt;A href="https://dev.splunk.com/enterprise/docs/developapps/kvstore/usetherestapitomanagekv/"&gt;https://dev.splunk.com/enterprise/docs/developapps/kvstore/usetherestapitomanagekv/&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;I was thinking delete might work this way, but I don't see it documented anywhere.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; curl -k -u admin:yourpassword -X DELETE \  
 &lt;A href="https://localhost:8089//servicesNS/nobody/search/storage/collections/data/collectionName" target="test_blank"&gt;https://localhost:8089//servicesNS/nobody/search/storage/collections/data/collectionName&lt;/A&gt; \
        -H 'Content-Type: application/json' \
        -d '[{"name": "001.001.001.001/29"}]'
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
      <pubDate>Fri, 27 Dec 2019 17:50:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/KV-store-keys-REST-API-and-URL-encoding-forward-slashes/m-p/473118#M81300</guid>
      <dc:creator>mydog8it</dc:creator>
      <dc:date>2019-12-27T17:50:14Z</dc:date>
    </item>
    <item>
      <title>Re: KV store keys,  REST API and URL encoding forward slashes</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/KV-store-keys-REST-API-and-URL-encoding-forward-slashes/m-p/473119#M81301</link>
      <description>&lt;P&gt;Unfortunately, no change in behavior.   Still a 404 with this format.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;/servicesNS/nobody/search/storage/collections/data/networks/010.009.009.009%2f29
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Fri, 27 Dec 2019 18:43:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/KV-store-keys-REST-API-and-URL-encoding-forward-slashes/m-p/473119#M81301</guid>
      <dc:creator>hughkelley</dc:creator>
      <dc:date>2019-12-27T18:43:34Z</dc:date>
    </item>
    <item>
      <title>Re: KV store keys,  REST API and URL encoding forward slashes</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/KV-store-keys-REST-API-and-URL-encoding-forward-slashes/m-p/473120#M81302</link>
      <description>&lt;P&gt;For this, you're going to want to follow a slightly different strategy as CIDR may not be unique in your KVStore, but the Key ID always will be. &lt;/P&gt;

&lt;P&gt;So instead of directly attempting to post the CIDR in the URL, you can add one extra step. &lt;/P&gt;

&lt;OL&gt;
&lt;LI&gt;Query for any records where your CIDR matches. An example I've used is &lt;CODE&gt;curl -k -u admin:password https://localhost:8089/servicesNS/nobody/search/storage/collections/data/kvstorecoll?query=%7B%22cidr%22%3A%20%221.2.4.7%2F24%22%7D
&lt;/CODE&gt;&lt;/LI&gt;
&lt;LI&gt;This will give you data back that shows all records with this CIDR. From there you can get the relevant key id's that you want to delete: &lt;/LI&gt;
&lt;/OL&gt;

&lt;BLOCKQUOTE&gt;
&lt;P&gt;[ { "name" : "Ryan", "cidr" : "1.2.4.7/24", "cidrnoslash" : "1.1.1.1", "_user" : "nobody", "_key" : "5e174b07e2edd2a9e9218e5a" } ]&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;

&lt;OL&gt;
&lt;LI&gt;You can then post a similar delete command, except with the Key ID, such as: &lt;CODE&gt;curl -k -u admin:password -X DELETE https://localhost:8089/servicesNS/nobody/search/storage/collections/data/kvstorecoll/5e174b07e2edd2a9e9218e5a -H 'Content-Type: application/json'&lt;/CODE&gt;&lt;/LI&gt;
&lt;/OL&gt;

&lt;P&gt;Hope this helps!&lt;/P&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:33:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/KV-store-keys-REST-API-and-URL-encoding-forward-slashes/m-p/473120#M81302</guid>
      <dc:creator>ryanoconnor</dc:creator>
      <dc:date>2020-09-30T03:33:21Z</dc:date>
    </item>
    <item>
      <title>Re: KV store keys,  REST API and URL encoding forward slashes</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/KV-store-keys-REST-API-and-URL-encoding-forward-slashes/m-p/473121#M81303</link>
      <description>&lt;P&gt;Unfortunately, I use the CIDR address as the _key value.   This was necessary so that I didn't have to track a separate ID.   When I use the query approach you describe I get the key in plain CIDR format.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;netCidr    : 99.99.6.0/23
_user      : nobody
_key       : 99.99.6.0/23
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm thinking this means I need to find a supported way to encode it.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Jan 2020 16:48:29 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/KV-store-keys-REST-API-and-URL-encoding-forward-slashes/m-p/473121#M81303</guid>
      <dc:creator>hughkelley</dc:creator>
      <dc:date>2020-01-09T16:48:29Z</dc:date>
    </item>
    <item>
      <title>Re: KV store keys,  REST API and URL encoding forward slashes</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/KV-store-keys-REST-API-and-URL-encoding-forward-slashes/m-p/473122#M81304</link>
      <description>&lt;P&gt;Granted, it's probably best to leave _key as something unique. That's usually a reserved field with a unique ID for each record (&lt;A href="https://dev.splunk.com/enterprise/docs/developapps/kvstore/aboutkvstorecollections/" target="_blank"&gt;https://dev.splunk.com/enterprise/docs/developapps/kvstore/aboutkvstorecollections/&lt;/A&gt;).&lt;/P&gt;

&lt;P&gt;You still should be able to make this work I believe. This is on my test instance, Splunk 8.0.1. Here is my sample commands and output:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;curl -k -u admin:password  https://localhost:8089/servicesNS/nobody/search/storage/collections/data/kvstorecoll

curl -k -u admin:password https://localhost:8089/servicesNS/nobody/search/storage/collections/data/kvstorecoll -H 'Content-Type: application/json' -d  '{"name": "Ryan", "netCidr": "'"99.99.6.0/23"'", "_key": "99.99.6.0/23"}'

curl -k -u admin:password https://localhost:8089/servicesNS/nobody/search/storage/collections/data/kvstorecoll -H 'Content-Type: application/json' -d  '{"name": "Ryan", "netCidr": "'"88.88.6.0/24"'", "_key": "88.88.6.0/24"}'

curl -k -u admin:password  https://localhost:8089/servicesNS/nobody/search/storage/collections/data/kvstorecoll

curl -k -u admin:password -X DELETE https://localhost:8089/servicesNS/nobody/search/storage/collections/data/kvstorecoll/99.99.6.0%2f23 -H 'Content-Type: application/json'

curl -k -u admin:password https://localhost:8089/servicesNS/nobody/search/storage/collections/data/kvstorecoll
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;&lt;STRONG&gt;Output:&lt;/STRONG&gt;&lt;/P&gt;

&lt;BLOCKQUOTE&gt;
&lt;PRE&gt;&lt;CODE&gt;ryan$ curl -k -u admin:password  https://localhost:8089/servicesNS/nobody/search/storage/collections/data/kvstorecoll
[ ]
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;ryan$ curl -k -u admin:password  &lt;A href="https://localhost:8089/servicesNS/nobody/search/storage/collections/data/kvstorecoll" target="_blank"&gt;https://localhost:8089/servicesNS/nobody/search/storage/collections/data/kvstorecoll&lt;/A&gt; -H 'Content-Type: application/json' -d  '{"name": "Ryan", "netCidr": "'"99.99./23"'", "_key": "99.99.6.0/23"}'&lt;BR /&gt;
   {"_key":"99.99.6.0/23"}&lt;/P&gt;

&lt;P&gt;ryan$ curl -k -u admin:password &lt;A href="https://localhost:8089/servicesNS/nobody/search/storage/collections/data/kvstorecoll" target="_blank"&gt;https://localhost:8089/servicesNS/nobody/search/storage/collections/data/kvstorecoll&lt;/A&gt; -H 'Content-Type: application/json' -d  '{"name": "Ryan", /24"'", "_key": "88.88.6.0/24"}'&lt;BR /&gt;
   {"_key":"88.88.6.0/24"}&lt;/P&gt;

&lt;P&gt;ryan$ curl -k -u admin:password &lt;A href="https://localhost:8089/servicesNS/nobody/search/storage/collections/data/kvstorecoll" target="_blank"&gt;https://localhost:8089/servicesNS/nobody/search/storage/collections/data/kvstorecoll&lt;/A&gt;&lt;BR /&gt;
   [ { "name" : "Ryan", "netCidr" : "88.88.6.0/24", "_user" : "nobody", "_key" : "88.88.6.0/24" }, { "name" : "Ryan", "netCidr" : "99.99.6.0/23", "_user" : "nobody", "_key" : "99.99.6.0/23" } ]&lt;/P&gt;

&lt;P&gt;ryan$ curl -k -u admin:password -X DELETE &lt;A href="https://localhost:8089/servicesNS/nobody/search/storage/collections/data/kvstorecoll/99.99.6.0%2f23" target="_blank"&gt;https://localhost:8089/servicesNS/nobody/search/storage/collections/data/kvstorecoll/99.99.6.0%2f23&lt;/A&gt; -H 'Content-Type: application/json'&lt;/P&gt;

&lt;P&gt;ryan$ curl -k -u admin:password &lt;A href="https://localhost:8089/servicesNS/nobody/search/storage/collections/data/kvstorecoll" target="_blank"&gt;https://localhost:8089/servicesNS/nobody/search/storage/collections/data/kvstorecoll&lt;/A&gt;&lt;BR /&gt;
   [ { "name" : "Ryan", "netCidr" : "88.88.6.0/24", "_user" : "nobody", "_key" : "88.88.6.0/24" }]&lt;/P&gt;
&lt;/BLOCKQUOTE&gt;</description>
      <pubDate>Wed, 30 Sep 2020 03:34:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/KV-store-keys-REST-API-and-URL-encoding-forward-slashes/m-p/473122#M81304</guid>
      <dc:creator>ryanoconnor</dc:creator>
      <dc:date>2020-09-30T03:34:20Z</dc:date>
    </item>
    <item>
      <title>Re: KV store keys,  REST API and URL encoding forward slashes</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/KV-store-keys-REST-API-and-URL-encoding-forward-slashes/m-p/473123#M81305</link>
      <description>&lt;P&gt;That bring us full circle.   This URL:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&lt;A href="https://xxx/servicesNS/nobody/search/storage/collections/data/networks/99.99.6.0%2f23" target="test_blank"&gt;https://xxx/servicesNS/nobody/search/storage/collections/data/networks/99.99.6.0%2f23&lt;/A&gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;gets me this result:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;WebCmdletWebResponseException

    Could not find object.

The remote server returned an error: (404) Not Found.
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I know the _key is in the collection because I do a full fetch of the collection at the beginning of the script.   This works with other types of data (usernames and other _key data) - just not these addresses.&lt;/P&gt;</description>
      <pubDate>Fri, 10 Jan 2020 17:27:03 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/KV-store-keys-REST-API-and-URL-encoding-forward-slashes/m-p/473123#M81305</guid>
      <dc:creator>hughkelley</dc:creator>
      <dc:date>2020-01-10T17:27:03Z</dc:date>
    </item>
  </channel>
</rss>

