<?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 do you create saved search using REST API call? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-create-saved-search-using-REST-API-call/m-p/435877#M76058</link>
    <description>&lt;P&gt;Should i add  a stanza to the input.conf?&lt;BR /&gt;
I have the same issue on create index as well.&lt;BR /&gt;
Please, Splunk gurus? Anybody knows the answer?&lt;/P&gt;</description>
    <pubDate>Fri, 14 Dec 2018 18:00:14 GMT</pubDate>
    <dc:creator>sp04355</dc:creator>
    <dc:date>2018-12-14T18:00:14Z</dc:date>
    <item>
      <title>How do you create saved search using REST API call?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-create-saved-search-using-REST-API-call/m-p/435876#M76057</link>
      <description>&lt;P&gt;Works in curl:&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;curl -k -u admin:changeme &lt;A href="http://localhost:8089/servicesNS/admin/search/saved/searches"&gt;http://localhost:8089/servicesNS/admin/search/saved/searches&lt;/A&gt;  -d name=MySavedSearch --data-urlencode search="index=_internal source=*metrics.log"&lt;/STRONG&gt;&lt;/P&gt;

&lt;P&gt;The same call from Postman:&lt;/P&gt;

&lt;P&gt;&lt;A href="http://localhost:8089//servicesNS/admin/launcher/saved/searches?name=%22MySavedSearch%22&amp;amp;search=%22index=_internal"&gt;http://localhost:8089//servicesNS/admin/launcher/saved/searches?name="MySavedSearch"&amp;amp;search="index=_internal&lt;/A&gt; source=*metrics.log"&lt;/P&gt;

&lt;P&gt;&amp;lt; &lt;STRONG&gt;ERROR"&amp;gt;Cannot perform action "POST" without a target name to act on&lt;/STRONG&gt;.&lt;/P&gt;

&lt;P&gt;What is the target name it   complains about?  I provided an application name as a target — not good enough?&lt;/P&gt;</description>
      <pubDate>Thu, 13 Dec 2018 00:16:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-create-saved-search-using-REST-API-call/m-p/435876#M76057</guid>
      <dc:creator>sp04355</dc:creator>
      <dc:date>2018-12-13T00:16:33Z</dc:date>
    </item>
    <item>
      <title>Re: How do you create saved search using REST API call?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-create-saved-search-using-REST-API-call/m-p/435877#M76058</link>
      <description>&lt;P&gt;Should i add  a stanza to the input.conf?&lt;BR /&gt;
I have the same issue on create index as well.&lt;BR /&gt;
Please, Splunk gurus? Anybody knows the answer?&lt;/P&gt;</description>
      <pubDate>Fri, 14 Dec 2018 18:00:14 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-create-saved-search-using-REST-API-call/m-p/435877#M76058</guid>
      <dc:creator>sp04355</dc:creator>
      <dc:date>2018-12-14T18:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: How do you create saved search using REST API call?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-create-saved-search-using-REST-API-call/m-p/435878#M76059</link>
      <description>&lt;P&gt;Hello @sp04355,&lt;/P&gt;

&lt;P&gt;Do you know the distinction between GET and POST requests? If not, you should probably google it. One important difference is that GET parameters are sent as part of the URL whereas POST parameters are sent in the request body after the HTTP headers.&lt;/P&gt;

&lt;P&gt;When you browse the &lt;A href="http://docs.splunk.com/Documentation/Splunk/7.2.1/RESTREF/RESTsearch"&gt;REST API Reference Manual&lt;/A&gt; then you will see that there are many functions which depend on the type of the request (GET, POST, DELETE...). GET is usually for requesting data whereas POST is for making changes.&lt;/P&gt;

&lt;P&gt;Your curl command above will run a POST request which looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;POST /servicesNS/admin/search/saved/searches HTTP/1.1
Authorization: Basic ...
User-Agent: curl/...
Host: localhost
Accept: */*
Content-Length: 66
Content-Type: application/x-www-form-urlencoded

name=MySavedSearch&amp;amp;search=index%3D_internal%20source%3Dmetrics.log
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Now I'm not familiar with Postman but from what I can see: You are explicitly putting the parameters in the URL instead of the request body. So you are sending a POST request without any valid parameters. That's why Splunk is complaining that it cannot find the "name=MySavedSearch" parameter.&lt;/P&gt;

&lt;P&gt;So I advice to check the Postman documentation on how to send a POST request.&lt;/P&gt;

&lt;P&gt;Side note 1: Why do you have "launcher" in the postman URL?&lt;BR /&gt;
Side note 2: I'm surprised to see that you are using http instead of https.&lt;/P&gt;</description>
      <pubDate>Sat, 15 Dec 2018 15:49:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-create-saved-search-using-REST-API-call/m-p/435878#M76059</guid>
      <dc:creator>whrg</dc:creator>
      <dc:date>2018-12-15T15:49:55Z</dc:date>
    </item>
    <item>
      <title>Re: How do you create saved search using REST API call?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-create-saved-search-using-REST-API-call/m-p/539209#M90335</link>
      <description>&lt;LI-CODE lang="markup"&gt;curl -k -u admin:changeme https://localhost:8089/services/saved/searches \
	-d name=firstApiTest \
	-d disabled=1 \
	-d owner=nobody \
	-d description=descritionText \
	-d search="index=main" \
	-d dispatch.index_earliest=-7d \
	-d dispatch.index_latestlatest=now&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 09 Feb 2021 17:53:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-create-saved-search-using-REST-API-call/m-p/539209#M90335</guid>
      <dc:creator>paulstark2</dc:creator>
      <dc:date>2021-02-09T17:53:38Z</dc:date>
    </item>
    <item>
      <title>Re: How do you create saved search using REST API call?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-create-saved-search-using-REST-API-call/m-p/649887#M110445</link>
      <description>&lt;P&gt;what the heck is a stanza?&lt;/P&gt;</description>
      <pubDate>Mon, 10 Jul 2023 17:48:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-create-saved-search-using-REST-API-call/m-p/649887#M110445</guid>
      <dc:creator>gerrysr6</dc:creator>
      <dc:date>2023-07-10T17:48:34Z</dc:date>
    </item>
    <item>
      <title>Re: How do you create saved search using REST API call?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-do-you-create-saved-search-using-REST-API-call/m-p/656185#M111145</link>
      <description>&lt;P&gt;Is there a way to pass these values from a file?&lt;/P&gt;&lt;PRE&gt;	-d name=firstApiTest \
	-d disabled=1 \
	-d owner=nobody \
	-d description=descritionText \
	-d search="index=main" \
	-d dispatch.index_earliest=-7d \
	-d dispatch.index_latestlatest=now&lt;/PRE&gt;</description>
      <pubDate>Thu, 31 Aug 2023 05:12:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-do-you-create-saved-search-using-REST-API-call/m-p/656185#M111145</guid>
      <dc:creator>damode1</dc:creator>
      <dc:date>2023-08-31T05:12:00Z</dc:date>
    </item>
  </channel>
</rss>

