<?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: How to make a POST request to Splunk API in a SimpleXML javascript dashboard? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-to-make-a-POST-request-to-Splunk-API-in-a-SimpleXML/m-p/511424#M86870</link>
    <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/56366"&gt;@herbatology&lt;/a&gt;&amp;nbsp; Did you find any solution to this? I am trying to find an answer for the same question. My use case is to post a Maintenance Window when a submit button on the dashboard is clicked.&lt;/P&gt;</description>
    <pubDate>Tue, 28 Jul 2020 23:33:11 GMT</pubDate>
    <dc:creator>divya1388</dc:creator>
    <dc:date>2020-07-28T23:33:11Z</dc:date>
    <item>
      <title>How to make a POST request to Splunk API in a SimpleXML javascript dashboard?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-make-a-POST-request-to-Splunk-API-in-a-SimpleXML/m-p/465998#M80311</link>
      <description>&lt;P&gt;How can I use the splunkjs "Service" class to make POST changes to .conf files via the REST API in a Splunk SimpleXML JavaScript Dashboard (embedded via &amp;lt;dashboard script="myscript.js"&amp;gt;)?&lt;/P&gt;

&lt;P&gt;I've tried to use the documentation, however it is unclear to me, if I can use this class in javascript in a SimpleXML dashboard and how.&lt;BR /&gt;
&lt;A href="https://docs.splunk.com/DocumentationStatic/JavaScriptSDK/1.0/splunkjs.Service.Endpoint.html#splunkjs.Service.Endpoint-post"&gt;https://docs.splunk.com/DocumentationStatic/JavaScriptSDK/1.0/splunkjs.Service.Endpoint.html#splunkjs.Service.Endpoint-post&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Previously I've used SearchManager objects to query the rest API via the "| rest" command, but apparently this command only allows GET requests and not POST. This is not suitable for me as I want to CHANGE a config file directly via a javascript call to the REST API, without a workaround with a custom python search command or elsewhat.&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;require([
    'jquery', 
    'underscore',
    'splunkjs/http',
    'splunkjs/service',
    'splunkjs/mvc',
    'splunkjs/mvc/searchmanager', 
    'splunkjs/mvc/simplexml/ready!'
], function($, _, Http, Service, mvc, SearchManager, TableView) {
      var endpoint = new splunkjs.Service.Endpoint(service, "search/jobs/12345");
     endpoint.post("control", {action: "cancel"}, function() { console.log("CANCELLED"))});
});
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 02 Apr 2020 17:11:13 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-make-a-POST-request-to-Splunk-API-in-a-SimpleXML/m-p/465998#M80311</guid>
      <dc:creator>herbatology</dc:creator>
      <dc:date>2020-04-02T17:11:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to make a POST request to Splunk API in a SimpleXML javascript dashboard?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-to-make-a-POST-request-to-Splunk-API-in-a-SimpleXML/m-p/511424#M86870</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/56366"&gt;@herbatology&lt;/a&gt;&amp;nbsp; Did you find any solution to this? I am trying to find an answer for the same question. My use case is to post a Maintenance Window when a submit button on the dashboard is clicked.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Jul 2020 23:33:11 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-to-make-a-POST-request-to-Splunk-API-in-a-SimpleXML/m-p/511424#M86870</guid>
      <dc:creator>divya1388</dc:creator>
      <dc:date>2020-07-28T23:33:11Z</dc:date>
    </item>
  </channel>
</rss>

