<?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 Correct syntax for service.post method for KV store?  (Splunk JS SDK) in Knowledge Management</title>
    <link>https://community.splunk.com/t5/Knowledge-Management/Correct-syntax-for-service-post-method-for-KV-store-Splunk-JS/m-p/332316#M2853</link>
    <description>&lt;P&gt;I"m trying to POST to a KV Store in JS. Currently, I'm able to use the &lt;A href="http://docs.splunk.com/DocumentationStatic/JavaScriptSDK/1.8.0/splunkjs.Service.html#splunkjs.Service%5Erequest"&gt;service.request method&lt;/A&gt;, with POST as the method type.  Example from the KV Store tutorial:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; service.request(
                "storage/collections/data/mycollection/",
                "POST",
                null,
                null,
                JSON.stringify(record),
                {"Content-Type": "application/json"},
                null)
                    .done(function() { 
                         (...)
                    });
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like to convert this syntax to the &lt;A href="http://docs.splunk.com/DocumentationStatic/JavaScriptSDK/1.8.0/splunkjs.Service.html#splunkjs.Service%5Epost+"&gt;service.post method&lt;/A&gt;. However, I don't know how to structure the params object to properly include the content-type header and record.  My best attempt:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; service.post("storage/collections/data/mycollection/",
                                                {
                                                    body: JSON.stringify(record),
                                                    headers: {
                                                        'Content-Type': 'application/json'
                                                    }
                                                },
                                                function() {
                                                    if(!err) (...); 
                                                }
                                            );
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This throws a 400 error, with an error message "Must supply 'Content-Type' header set to 'application/json'&lt;/P&gt;

&lt;P&gt;Any ideas on how to proceed?&lt;/P&gt;</description>
    <pubDate>Wed, 01 Mar 2017 15:54:27 GMT</pubDate>
    <dc:creator>nprab428</dc:creator>
    <dc:date>2017-03-01T15:54:27Z</dc:date>
    <item>
      <title>Correct syntax for service.post method for KV store?  (Splunk JS SDK)</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Correct-syntax-for-service-post-method-for-KV-store-Splunk-JS/m-p/332316#M2853</link>
      <description>&lt;P&gt;I"m trying to POST to a KV Store in JS. Currently, I'm able to use the &lt;A href="http://docs.splunk.com/DocumentationStatic/JavaScriptSDK/1.8.0/splunkjs.Service.html#splunkjs.Service%5Erequest"&gt;service.request method&lt;/A&gt;, with POST as the method type.  Example from the KV Store tutorial:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; service.request(
                "storage/collections/data/mycollection/",
                "POST",
                null,
                null,
                JSON.stringify(record),
                {"Content-Type": "application/json"},
                null)
                    .done(function() { 
                         (...)
                    });
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I would like to convert this syntax to the &lt;A href="http://docs.splunk.com/DocumentationStatic/JavaScriptSDK/1.8.0/splunkjs.Service.html#splunkjs.Service%5Epost+"&gt;service.post method&lt;/A&gt;. However, I don't know how to structure the params object to properly include the content-type header and record.  My best attempt:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; service.post("storage/collections/data/mycollection/",
                                                {
                                                    body: JSON.stringify(record),
                                                    headers: {
                                                        'Content-Type': 'application/json'
                                                    }
                                                },
                                                function() {
                                                    if(!err) (...); 
                                                }
                                            );
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;This throws a 400 error, with an error message "Must supply 'Content-Type' header set to 'application/json'&lt;/P&gt;

&lt;P&gt;Any ideas on how to proceed?&lt;/P&gt;</description>
      <pubDate>Wed, 01 Mar 2017 15:54:27 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Correct-syntax-for-service-post-method-for-KV-store-Splunk-JS/m-p/332316#M2853</guid>
      <dc:creator>nprab428</dc:creator>
      <dc:date>2017-03-01T15:54:27Z</dc:date>
    </item>
    <item>
      <title>Re: Correct syntax for service.post method for KV store?  (Splunk JS SDK)</title>
      <link>https://community.splunk.com/t5/Knowledge-Management/Correct-syntax-for-service-post-method-for-KV-store-Splunk-JS/m-p/332317#M2854</link>
      <description>&lt;P&gt;have u found solution for this issue?&lt;/P&gt;</description>
      <pubDate>Thu, 21 Jun 2018 06:59:44 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Knowledge-Management/Correct-syntax-for-service-post-method-for-KV-store-Splunk-JS/m-p/332317#M2854</guid>
      <dc:creator>kartikm4023</dc:creator>
      <dc:date>2018-06-21T06:59:44Z</dc:date>
    </item>
  </channel>
</rss>

