<?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 KV Store API successful POST but no added entry? in Knowledge Management</title>
    <link>https://community.splunk.com/t5/Knowledge-Management/KV-Store-API-successful-POST-but-no-added-entry/m-p/413770#M3633</link>
    <description>&lt;P&gt;I am stuck using the KV Store API to insert a record. I have a record object that I am posting the following way using this doc: &lt;A href="https://docs.splunk.com/DocumentationStatic/JavaScriptSDK/1.6/splunkjs.Service.html#splunkjs.Service%5Erequest"&gt;https://docs.splunk.com/DocumentationStatic/JavaScriptSDK/1.6/splunkjs.Service.html#splunkjs.Service^request&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;            var record = {"data" : myData};
    var path = "storage/collections/data/myCollection/";
    var method = "POST";
    var query=null;
    var post=null;
    var body=JSON.stringify(record);
    var headers={"Content-Type": "application/json"};

    service.request(
        path,
        method,
        query,
        post,
        body,
        headers,
        //callback function
        function(err, response){
            if(response) console.log("response " + JSON.stringify(response));
            else console.log("err " + JSON.stringify(err));
        }
    );
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My console log is giving the following success message with a 201, indicating a record was created:&lt;/P&gt;

&lt;P&gt;{"response":{"statusCode":201,"headers":{"date":"Thu, 25 Jul 2019 13:47:48 GMT\r","x-content-type-options":"nosniff\r","server":"Splunkd\r","x-frame-options":"SAMEORIGIN\r","content-type":"application/json; charset=UTF-8\r","cache-control":"no-store, no-cache, must-revalidate, max-age=0\r","connection":"Keep-Alive\r","vary":"Cookie\r","content-length":"35\r","expires":"Thu, 26 Oct 1978 00:00:00 GMT\r"}},"status":201,"data":{"_key":"5d39b3047369c10c940059c8"},"error":"success"}&lt;/P&gt;

&lt;P&gt;However, when I search my |inputlookup myCollection there is no added entry. The response message returns an _key, but when I search this in splunk nothing comes back. I am not sure how to debug because the code says it is successful. Can anyone please advise?&lt;/P&gt;</description>
    <pubDate>Thu, 25 Jul 2019 14:04:25 GMT</pubDate>
    <dc:creator>bofasplunkguy</dc:creator>
    <dc:date>2019-07-25T14:04:25Z</dc:date>
    <item>
      <title>KV Store API successful POST but no added entry?</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/KV-Store-API-successful-POST-but-no-added-entry/m-p/413770#M3633</link>
      <description>&lt;P&gt;I am stuck using the KV Store API to insert a record. I have a record object that I am posting the following way using this doc: &lt;A href="https://docs.splunk.com/DocumentationStatic/JavaScriptSDK/1.6/splunkjs.Service.html#splunkjs.Service%5Erequest"&gt;https://docs.splunk.com/DocumentationStatic/JavaScriptSDK/1.6/splunkjs.Service.html#splunkjs.Service^request&lt;/A&gt;&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;            var record = {"data" : myData};
    var path = "storage/collections/data/myCollection/";
    var method = "POST";
    var query=null;
    var post=null;
    var body=JSON.stringify(record);
    var headers={"Content-Type": "application/json"};

    service.request(
        path,
        method,
        query,
        post,
        body,
        headers,
        //callback function
        function(err, response){
            if(response) console.log("response " + JSON.stringify(response));
            else console.log("err " + JSON.stringify(err));
        }
    );
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;My console log is giving the following success message with a 201, indicating a record was created:&lt;/P&gt;

&lt;P&gt;{"response":{"statusCode":201,"headers":{"date":"Thu, 25 Jul 2019 13:47:48 GMT\r","x-content-type-options":"nosniff\r","server":"Splunkd\r","x-frame-options":"SAMEORIGIN\r","content-type":"application/json; charset=UTF-8\r","cache-control":"no-store, no-cache, must-revalidate, max-age=0\r","connection":"Keep-Alive\r","vary":"Cookie\r","content-length":"35\r","expires":"Thu, 26 Oct 1978 00:00:00 GMT\r"}},"status":201,"data":{"_key":"5d39b3047369c10c940059c8"},"error":"success"}&lt;/P&gt;

&lt;P&gt;However, when I search my |inputlookup myCollection there is no added entry. The response message returns an _key, but when I search this in splunk nothing comes back. I am not sure how to debug because the code says it is successful. Can anyone please advise?&lt;/P&gt;</description>
      <pubDate>Thu, 25 Jul 2019 14:04:25 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/KV-Store-API-successful-POST-but-no-added-entry/m-p/413770#M3633</guid>
      <dc:creator>bofasplunkguy</dc:creator>
      <dc:date>2019-07-25T14:04:25Z</dc:date>
    </item>
  </channel>
</rss>

