<?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: Is there a way to update existing values in KV store via REST API? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Is-there-a-way-to-update-existing-values-in-KV-store-via-REST/m-p/221281#M43437</link>
    <description>&lt;P&gt;I'm not that familiar with using the REST API with KV Store, but in case this is useful:&lt;/P&gt;

&lt;P&gt;There is information about updating on the page &lt;A href="http://dev.splunk.com/view/SP-CAAAEZG"&gt;Use the REST API to manage KV Store collections and data&lt;/A&gt;.&lt;/P&gt;

&lt;P&gt;There are also some examples in the REST API Reference, for instance: &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.5.0/RESTREF/RESTkvstoreExamples#storage.2Fcollections.2Fconfig.2F.7Bcollection.7D_POST"&gt;storage/collections/config/{collection} POST&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Tue, 15 Nov 2016 23:50:21 GMT</pubDate>
    <dc:creator>ChrisG</dc:creator>
    <dc:date>2016-11-15T23:50:21Z</dc:date>
    <item>
      <title>Is there a way to update existing values in KV store via REST API?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-there-a-way-to-update-existing-values-in-KV-store-via-REST/m-p/221280#M43436</link>
      <description>&lt;P&gt;Like insert and delete, do we have any rest implementation for update? Or is there anyway to update the existing  values of kvstore &lt;/P&gt;

&lt;P&gt;reference:&lt;BR /&gt;
&lt;A href="http://dev.splunk.com/view/SP-CAAAEZX"&gt;http://dev.splunk.com/view/SP-CAAAEZX&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;for  insert:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; // Use the request method to send a REST POST request
            // to the storage/collections/data/{collection}/ endpoint
            service.request(
                "storage/collections/data/mycollection/",
                "POST",
                null,
                null,
                JSON.stringify(record),
                {"Content-Type": "application/json"},
                null)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;for delete:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;/ Delete the record that corresponds to the key ID using
            // the del method to send a DELETE request
            // to the storage/collections/data/{collection}/ endpoint
            service.del("storage/collections/data/mycollection/" + encodeURIComponent(form_keyid))
                .done(function() {
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2016 23:26:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-there-a-way-to-update-existing-values-in-KV-store-via-REST/m-p/221280#M43436</guid>
      <dc:creator>splunk403</dc:creator>
      <dc:date>2016-11-15T23:26:20Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to update existing values in KV store via REST API?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-there-a-way-to-update-existing-values-in-KV-store-via-REST/m-p/221281#M43437</link>
      <description>&lt;P&gt;I'm not that familiar with using the REST API with KV Store, but in case this is useful:&lt;/P&gt;

&lt;P&gt;There is information about updating on the page &lt;A href="http://dev.splunk.com/view/SP-CAAAEZG"&gt;Use the REST API to manage KV Store collections and data&lt;/A&gt;.&lt;/P&gt;

&lt;P&gt;There are also some examples in the REST API Reference, for instance: &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.5.0/RESTREF/RESTkvstoreExamples#storage.2Fcollections.2Fconfig.2F.7Bcollection.7D_POST"&gt;storage/collections/config/{collection} POST&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 15 Nov 2016 23:50:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-there-a-way-to-update-existing-values-in-KV-store-via-REST/m-p/221281#M43437</guid>
      <dc:creator>ChrisG</dc:creator>
      <dc:date>2016-11-15T23:50:21Z</dc:date>
    </item>
    <item>
      <title>Re: Is there a way to update existing values in KV store via REST API?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-there-a-way-to-update-existing-values-in-KV-store-via-REST/m-p/221282#M43438</link>
      <description>&lt;P&gt;You can update a kv value by doing the same &lt;CODE&gt;service.request()&lt;/CODE&gt; as you do for an insert but just modify the REST API call. Which is to add the _key for the record after your collection &lt;CODE&gt;https&lt;/CODE&gt;://&amp;lt; localhost &amp;gt;/..data/mycollction/&lt;STRONG&gt;&lt;EM&gt;keyID&lt;/EM&gt;&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;The only other thing you need to remember to do is make sure the &lt;CODE&gt;record&lt;/CODE&gt; includes all your other key values, or else it will update those to empty&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;         var record = { 
                "CustID": form_id, 
                "CustName": form_name, 
                "CustStreet": form_street,
                "CustCity": form_city,
                "CustState": form_state,
                "CustZip": form_zip 
         }; 

         var keyID = '5410be5441ba15298e4624d1'

         service.request(
             "storage/collections/data/mycollection/" + encodeURIComponent(keyID),
             "POST",
             null,
             null,
             JSON.stringify(record),
             {"Content-Type": "application/json"},
             null);
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Tue, 28 Feb 2017 23:55:20 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-there-a-way-to-update-existing-values-in-KV-store-via-REST/m-p/221282#M43438</guid>
      <dc:creator>illescas</dc:creator>
      <dc:date>2017-02-28T23:55:20Z</dc:date>
    </item>
  </channel>
</rss>

