<?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 Splunk Adaptive Response sending post command in REST API in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-Adaptive-Response-sending-post-command-in-REST-API/m-p/314769#M58935</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am trying to create a new app which will be used to send a Splunk Adaptive response via REST API. I am able get the response from Splunk REST API using using below code&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;     headers_server, content_server = rest.simpleRequest('/services/server/info?output_mode=json', sessionKey=sessionKey)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However my requirement is to convert the below curl command which has a POST action to python REST API. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;curl -k -u admin:Password1 &lt;A href="https://localhost:8089/services/data/inputs/script/restart?output_mode=json" target="test_blank"&gt;https://localhost:8089/services/data/inputs/script/restart?output_mode=json&lt;/A&gt; -d script=".\bin\script_test\windows.bat"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Would require you help on how to send this POST command in python REST API format.&lt;/P&gt;</description>
    <pubDate>Wed, 29 Nov 2017 14:38:26 GMT</pubDate>
    <dc:creator>ramesh_babu71</dc:creator>
    <dc:date>2017-11-29T14:38:26Z</dc:date>
    <item>
      <title>Splunk Adaptive Response sending post command in REST API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-Adaptive-Response-sending-post-command-in-REST-API/m-p/314769#M58935</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I am trying to create a new app which will be used to send a Splunk Adaptive response via REST API. I am able get the response from Splunk REST API using using below code&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;     headers_server, content_server = rest.simpleRequest('/services/server/info?output_mode=json', sessionKey=sessionKey)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;However my requirement is to convert the below curl command which has a POST action to python REST API. &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;curl -k -u admin:Password1 &lt;A href="https://localhost:8089/services/data/inputs/script/restart?output_mode=json" target="test_blank"&gt;https://localhost:8089/services/data/inputs/script/restart?output_mode=json&lt;/A&gt; -d script=".\bin\script_test\windows.bat"
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Would require you help on how to send this POST command in python REST API format.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2017 14:38:26 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-Adaptive-Response-sending-post-command-in-REST-API/m-p/314769#M58935</guid>
      <dc:creator>ramesh_babu71</dc:creator>
      <dc:date>2017-11-29T14:38:26Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Adaptive Response sending post command in REST API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-Adaptive-Response-sending-post-command-in-REST-API/m-p/314770#M58936</link>
      <description>&lt;P&gt;Hi @ramesh_babu71,&lt;/P&gt;

&lt;P&gt;Please try this python code&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;   rest.simpleRequest('/services/data/inputs/script/restart', sessionKey=sessionKey, postargs={'script': ".\bin\script_test\windows.bat"}, method='POST', raiseAllErrors=True)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;EDIT1: Updated code, but what you want to achieve. It seems like &lt;CODE&gt;/services/data/inputs/script/restart&lt;/CODE&gt;giving me HTTP 400 error with GET request but didn't tried POST request.&lt;/P&gt;

&lt;P&gt;EDIT2: Based on this doc &lt;A href="http://docs.splunk.com/Documentation/Splunk/6.6.4/RESTREF/RESTinput#data.2Finputs.2Fscript.2Frestart"&gt;http://docs.splunk.com/Documentation/Splunk/6.6.4/RESTREF/RESTinput#data.2Finputs.2Fscript.2Frestart&lt;/A&gt;&lt;BR /&gt;
POST request should be like&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;rest.simpleRequest('/servicesNS/nobody/&amp;lt;APPNAME&amp;gt;/data/inputs/script/restart', sessionKey=sessionKey, postargs={'script': ".\bin\script_test\windows.bat"}, method='POST', raiseAllErrors=True)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Wed, 29 Nov 2017 15:33:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-Adaptive-Response-sending-post-command-in-REST-API/m-p/314770#M58936</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2017-11-29T15:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Adaptive Response sending post command in REST API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-Adaptive-Response-sending-post-command-in-REST-API/m-p/314771#M58937</link>
      <description>&lt;P&gt;Thanks Harshil. This is what I was looking for. The POST command lets me to restart/enable the scripted input&lt;/P&gt;

&lt;P&gt;However a slight modification was required as &lt;STRONG&gt;\b&lt;/STRONG&gt; in &lt;STRONG&gt;".\bin...."&lt;/STRONG&gt;python is taken as ASCII so we have to tell python to take it as string using &lt;STRONG&gt;r&lt;/STRONG&gt; in front&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt; rest.simpleRequest('/services/data/inputs/script/restart', sessionKey=sessionKey, postargs={'script': r".\bin\script_test\windows.bat"}, method='POST', raiseAllErrors=True)
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Thu, 30 Nov 2017 17:25:50 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-Adaptive-Response-sending-post-command-in-REST-API/m-p/314771#M58937</guid>
      <dc:creator>ramesh_babu71</dc:creator>
      <dc:date>2017-11-30T17:25:50Z</dc:date>
    </item>
    <item>
      <title>Re: Splunk Adaptive Response sending post command in REST API</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Splunk-Adaptive-Response-sending-post-command-in-REST-API/m-p/314772#M58938</link>
      <description>&lt;P&gt;Great that it helped you,  I have converted my comment to answer so you can accept it and thanks for the explanation about ASCII character.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Nov 2017 17:29:24 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Splunk-Adaptive-Response-sending-post-command-in-REST-API/m-p/314772#M58938</guid>
      <dc:creator>harsmarvania57</dc:creator>
      <dc:date>2017-11-30T17:29:24Z</dc:date>
    </item>
  </channel>
</rss>

