<?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: HTTP Post request using REST API not returning results in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/HTTP-Post-request-using-REST-API-not-returning-results/m-p/85141#M21726</link>
    <description>&lt;P&gt;As indicated in the &lt;A href="http://docs.splunk.com/Documentation/Splunk/5.0/RESTAPI/RESTsearch#search.2Fjobs.2Fexport"&gt;docs&lt;/A&gt;, this endpoint expects a GET, not a POST.&lt;/P&gt;</description>
    <pubDate>Tue, 09 Oct 2012 18:26:55 GMT</pubDate>
    <dc:creator>gkanapathy</dc:creator>
    <dc:date>2012-10-09T18:26:55Z</dc:date>
    <item>
      <title>HTTP Post request using REST API not returning results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/HTTP-Post-request-using-REST-API-not-returning-results/m-p/85140#M21725</link>
      <description>&lt;P&gt;I am using ASP.NET with C# to call a search job in Splunk. When I run the search in Splunk, it returns results but the HTTP Post is not working. Here is the code:&lt;/P&gt;

&lt;P&gt;string URL = "&lt;A href="https://1.1.1.1:8089/servicesNS/admin/MyApp/search/jobs/export/"&gt;https://1.1.1.1:8089/servicesNS/admin/MyApp/search/jobs/export/&lt;/A&gt;";&lt;/P&gt;

&lt;P&gt;HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL);&lt;/P&gt;

&lt;P&gt;request.UserAgent = "GUI";&lt;/P&gt;

&lt;P&gt;request.Method = "POST;&lt;/P&gt;

&lt;P&gt;request.ContentType = "application/x-www-form-urlencoded";&lt;/P&gt;

&lt;P&gt;string requestVars = String.Format("output_mode=json&amp;amp;search=search%20192.168.1.1");&lt;/P&gt;

&lt;P&gt;request.ContentLength = requestVars.Length;&lt;/P&gt;

&lt;P&gt;Please help.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2012 17:48:53 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/HTTP-Post-request-using-REST-API-not-returning-results/m-p/85140#M21725</guid>
      <dc:creator>mznikkip</dc:creator>
      <dc:date>2012-10-09T17:48:53Z</dc:date>
    </item>
    <item>
      <title>Re: HTTP Post request using REST API not returning results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/HTTP-Post-request-using-REST-API-not-returning-results/m-p/85141#M21726</link>
      <description>&lt;P&gt;As indicated in the &lt;A href="http://docs.splunk.com/Documentation/Splunk/5.0/RESTAPI/RESTsearch#search.2Fjobs.2Fexport"&gt;docs&lt;/A&gt;, this endpoint expects a GET, not a POST.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2012 18:26:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/HTTP-Post-request-using-REST-API-not-returning-results/m-p/85141#M21726</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2012-10-09T18:26:55Z</dc:date>
    </item>
    <item>
      <title>Re: HTTP Post request using REST API not returning results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/HTTP-Post-request-using-REST-API-not-returning-results/m-p/85142#M21727</link>
      <description>&lt;P&gt;It says it is identical to POST, so if I change it to a GET there are still no results returned.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2012 21:38:39 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/HTTP-Post-request-using-REST-API-not-returning-results/m-p/85142#M21727</guid>
      <dc:creator>mznikkip</dc:creator>
      <dc:date>2012-10-09T21:38:39Z</dc:date>
    </item>
    <item>
      <title>Re: HTTP Post request using REST API not returning results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/HTTP-Post-request-using-REST-API-not-returning-results/m-p/85143#M21728</link>
      <description>&lt;P&gt;Firstly , this endpoint uses the GET HTTP Method.The docs simply make reference to another  endpoint with similar parameters that uses the POST HTTP Method.&lt;BR /&gt;
That aside , lets debug why you are not getting results.&lt;BR /&gt;
What HTTP status code is being returned ?&lt;BR /&gt;
Are there any error messages or diagnostic outputs you can share ?&lt;BR /&gt;
I can't see where you are &lt;A href="http://dev.splunk.com/view/rest-api-overview/SP-CAAADP8"&gt;setting your session key&lt;/A&gt; in the Authorization header.&lt;BR /&gt;
ie:&lt;BR /&gt;
request.Authorization = "Splunk 1611a2464777534359db26545612e";&lt;/P&gt;

&lt;P&gt;Furthermore , have you checked out our &lt;A href="http://dev.splunk.com/view/sdks/SP-CAAADP7"&gt;Developer SDKs&lt;/A&gt; , they make programming against the Splunk REST API a lot simpler than coding directly at the REST layer where it is easy to make mistakes. There is a C# SDK in a private repository on Github also.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2012 22:29:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/HTTP-Post-request-using-REST-API-not-returning-results/m-p/85143#M21728</guid>
      <dc:creator>Damien_Dallimor</dc:creator>
      <dc:date>2012-10-09T22:29:56Z</dc:date>
    </item>
    <item>
      <title>Re: HTTP Post request using REST API not returning results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/HTTP-Post-request-using-REST-API-not-returning-results/m-p/85144#M21729</link>
      <description>&lt;P&gt;It does &lt;EM&gt;not&lt;/EM&gt; say it is identical to a POST. It says it takes the same parameters as a POST to a &lt;EM&gt;different&lt;/EM&gt; endpoint.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Oct 2012 22:52:00 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/HTTP-Post-request-using-REST-API-not-returning-results/m-p/85144#M21729</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2012-10-09T22:52:00Z</dc:date>
    </item>
    <item>
      <title>Re: HTTP Post request using REST API not returning results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/HTTP-Post-request-using-REST-API-not-returning-results/m-p/85145#M21730</link>
      <description>&lt;P&gt;string url = "&lt;A href="https://1.1.1.1:8089/servicesNS/admin/MyApp/search/jobs/export/"&gt;https://1.1.1.1:8089/servicesNS/admin/MyApp/search/jobs/export/&lt;/A&gt;";&lt;/P&gt;

&lt;P&gt;HttpWebRequest req = (HttpWebRequest)WebRequest.Create(url);&lt;/P&gt;

&lt;P&gt;req.Credentials = new NetworkCredential(user, pw);&lt;/P&gt;

&lt;P&gt;ServicePointManager.ServerCertificateValidationCallback += delegate { return true; };&lt;/P&gt;

&lt;P&gt;request.Method = "GET";&lt;/P&gt;

&lt;P&gt;string vars = String.Format("output_mode=json&amp;amp;search=search%20192.1.1.1");&lt;/P&gt;

&lt;P&gt;using (WebResponse response = request.GetResponse()){..}&lt;BR /&gt;
...&lt;/P&gt;

&lt;P&gt;When I run this code, an exception occurs at 'using (WebResponse response = request.GetResponse())'- 400 error bad request.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2012 13:25:38 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/HTTP-Post-request-using-REST-API-not-returning-results/m-p/85145#M21730</guid>
      <dc:creator>mznikkip</dc:creator>
      <dc:date>2012-10-10T13:25:38Z</dc:date>
    </item>
    <item>
      <title>Re: HTTP Post request using REST API not returning results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/HTTP-Post-request-using-REST-API-not-returning-results/m-p/85146#M21731</link>
      <description>&lt;P&gt;As an FYI, long ago I used the POST which I had no problems with. I'm assuming during an upgrade that the endpoint functionality changed from POST to GET.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2012 14:06:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/HTTP-Post-request-using-REST-API-not-returning-results/m-p/85146#M21731</guid>
      <dc:creator>mznikkip</dc:creator>
      <dc:date>2012-10-10T14:06:43Z</dc:date>
    </item>
    <item>
      <title>Re: HTTP Post request using REST API not returning results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/HTTP-Post-request-using-REST-API-not-returning-results/m-p/85147#M21732</link>
      <description>&lt;P&gt;I also don't see anywhere where the string &lt;CODE&gt;vars&lt;/CODE&gt; is attached to the &lt;CODE&gt;request&lt;/CODE&gt; object (or appended to the URL)&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2012 14:56:43 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/HTTP-Post-request-using-REST-API-not-returning-results/m-p/85147#M21732</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2012-10-10T14:56:43Z</dc:date>
    </item>
    <item>
      <title>Re: HTTP Post request using REST API not returning results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/HTTP-Post-request-using-REST-API-not-returning-results/m-p/85148#M21733</link>
      <description>&lt;P&gt;Ahh right. Good catch!&lt;/P&gt;

&lt;P&gt;...&lt;BR /&gt;
string vars = String.Format("output_mode=json&amp;amp;search=search%20192.1.1.1");&lt;BR /&gt;
string url = "&lt;A href="https://1.1.1.1:8089/servicesNS/admin/MyApp/search/jobs/export?"&gt;https://1.1.1.1:8089/servicesNS/admin/MyApp/search/jobs/export?&lt;/A&gt;" + vars;&lt;BR /&gt;
using (WebResponse response = request.GetResponse())&lt;BR /&gt;
{&lt;BR /&gt;
   using (Stream stream = response.GetResponseStream())&lt;BR /&gt;
   {&lt;BR /&gt;
      StreamReader reader = new StreamReader(stream);&lt;BR /&gt;
      responseText = reader.ReadToEnd();&lt;BR /&gt;
   }&lt;BR /&gt;
}&lt;/P&gt;

&lt;P&gt;The request now is sent but in trying to retrieve the response, the data is huge. Trying to break it up into chunks of data to display in a table. Thanks for your help!&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2012 16:21:36 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/HTTP-Post-request-using-REST-API-not-returning-results/m-p/85148#M21733</guid>
      <dc:creator>mznikkip</dc:creator>
      <dc:date>2012-10-10T16:21:36Z</dc:date>
    </item>
    <item>
      <title>Re: HTTP Post request using REST API not returning results</title>
      <link>https://community.splunk.com/t5/Splunk-Search/HTTP-Post-request-using-REST-API-not-returning-results/m-p/85149#M21734</link>
      <description>&lt;P&gt;if it's too big, you might instead run with the search/jobs (not search/jobs/export) endpoint (it takes POST with the same parameters), maybe using the &lt;CODE&gt;exec_mode=blocking&lt;/CODE&gt;. You'll then get back a search id, and then you can page through the results and request them from the server under your control. that's probably the better approach for extremely large result sets that need to be chunked.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Oct 2012 17:22:40 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/HTTP-Post-request-using-REST-API-not-returning-results/m-p/85149#M21734</guid>
      <dc:creator>gkanapathy</dc:creator>
      <dc:date>2012-10-10T17:22:40Z</dc:date>
    </item>
  </channel>
</rss>

