<?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 How come our Splunk 6.5 REST API calls with curl command are not working? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/How-come-our-Splunk-6-5-REST-API-calls-with-curl-command-are-not/m-p/440934#M76854</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have the following REST call on a new 6.5 environment, and it's coming back with error&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;curl -X POST -u user:pass -k &lt;A href="http://host.domain.com:8000/en-US/splunkd/services/search/jobs" target="test_blank"&gt;http://host.domain.com:8000/en-US/splunkd/services/search/jobs&lt;/A&gt; -d search="search *"

 &amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&amp;gt;
  &amp;lt;!--
  This is a static HTML string template to render errors.  To edit this template, see appserver/mrsparkle/lib/error.py.
  --&amp;gt;
   &amp;lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:splunk="http://www.splunk.com/xhtml-extensions/1.0" xml:lang="en"&amp;gt;
   &amp;lt;head&amp;gt;
  &amp;lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&amp;gt;
  &amp;lt;link rel="shortcut icon" href="/en-
  US/static/@EA9E3236A0BA7C4B28247E726C3C7D69A561FB26DFC20737824C1922C733518A/img/favicon.ico" /&amp;gt;
 &amp;lt;title&amp;gt;Splunk cannot authenticate the request. CSRF validation failed. - Splunk&amp;lt;/title&amp;gt;
 &amp;lt;style&amp;gt;
     *       { margin: 0; padding: 0; }
    body    { font-family: helvetica, arial, sans-serif; color: #333; padding: 20px; }
    p,pre   { margin-bottom: 1em; font-size: .8em; }
    .status { font-size: .7em; color: #999; margin-bottom: 1em; }
    .msg    { margin-bottom: 1em; font-size: 1.4em;}
    pre     { font-family: Monaco,Courier Bold,Courier New,monospace; font-size: .7em;background-color: #eee;  padding: 5px;}
    #toggle { font-size: .8em; margin-bottom: 1em; }
    .byline { color: #555; }
    .byline span { font-weight: bold; line-height: 1.4em; }
    hr      { height: 1px; background-color: #ccc; border: 0; margin: 20px 0 10px; }
    h2      { font-size: 1em; margin-bottom: 1em; }
    table   { border-collapse: collapse; }
    td      { padding: 2px; }
    td.k    { font-family: helvetica, arial, sans-serif; font-weight: bold; }
    #debug  { display: none; }
    #crashes { margin: 20px 0; padding: 10px; border: 1px solid #800; }
    #crashes dt { font-size: 12px; margin-bottom: 5px; }
    #crashes dd { white-space: pre; background: #f2f2f2; padding: 10px; margin-left: 20px; display: none; font: 10px Monaco,Courier Bold,Courier New,monospace; }
&amp;lt;/style&amp;gt;
&amp;lt;script&amp;gt;
    function toggle(what) {
        what = document.getElementById(what);
        if (what.style.display == 'block') {
            what.style.display = 'none';
        } else {
            what.style.display = 'block';
        }
    }
&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
   &amp;lt;p class="status"&amp;gt;401 Unauthorized&amp;lt;/p&amp;gt;
   &amp;lt;p class="homelink"&amp;gt;&amp;lt;a href="/"&amp;gt;Return to Splunk home page&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
    &amp;lt;h1 class="msg"&amp;gt;Splunk cannot authenticate the request. CSRF validation failed.&amp;lt;/h1&amp;gt;
      &amp;lt;a href="/en-US/app/search/search?q=index%3D_internal%20host%3D%22xxx%22%20source%3D%2Aweb_service.log%20log_level%3DERROR%20requestid%3D5c1a06af277fdd04614990" target="_blank"&amp;gt;View more information about your request (request ID = 5c1a06af277fdd04614990) in 
   Search&amp;lt;/a&amp;gt;
    &amp;amp;lt;br/&amp;amp;gt;
   &amp;amp;lt;br/&amp;amp;gt;
  &amp;amp;lt;br/&amp;amp;gt;
 &amp;lt;hr /&amp;gt;
 &amp;lt;p class="byline"&amp;gt;You are using &amp;lt;span&amp;gt;xxxx.xxxxx.com:8000&amp;lt;/span&amp;gt;, which is connected to splunkd 
&amp;lt;span&amp;gt;@59c8927def0f&amp;lt;/span&amp;gt; at &amp;lt;span&amp;gt;https://127.0.0.1:8089&amp;lt;/span&amp;gt; on &amp;lt;span&amp;gt;Wed Dec 19 03:51:59 2018&amp;lt;/span&amp;gt;.&amp;lt;/p&amp;gt;
 &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm able to get the session key with same credentials :-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;curl -k &lt;A href="http://host.domain.com:8000/en-US/splunkd/services/auth/login" target="test_blank"&gt;http://host.domain.com:8000/en-US/splunkd/services/auth/login&lt;/A&gt; --data-urlencode username=user--data-urlencode password=pass

&amp;lt;response&amp;gt;
 &amp;lt;sessionKey&amp;gt;yATMHjpws9MOIGi5Rg9QvsoRR4EMncSGxlerJ9W6B....&amp;lt;/sessionKey&amp;gt;
&amp;lt;/response&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please suggest. Apologies for the editing, I'm new at this.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Wed, 19 Dec 2018 09:04:46 GMT</pubDate>
    <dc:creator>mukesh2019</dc:creator>
    <dc:date>2018-12-19T09:04:46Z</dc:date>
    <item>
      <title>How come our Splunk 6.5 REST API calls with curl command are not working?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-come-our-Splunk-6-5-REST-API-calls-with-curl-command-are-not/m-p/440934#M76854</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;

&lt;P&gt;I have the following REST call on a new 6.5 environment, and it's coming back with error&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;curl -X POST -u user:pass -k &lt;A href="http://host.domain.com:8000/en-US/splunkd/services/search/jobs" target="test_blank"&gt;http://host.domain.com:8000/en-US/splunkd/services/search/jobs&lt;/A&gt; -d search="search *"

 &amp;lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&amp;gt;
  &amp;lt;!--
  This is a static HTML string template to render errors.  To edit this template, see appserver/mrsparkle/lib/error.py.
  --&amp;gt;
   &amp;lt;html xmlns="http://www.w3.org/1999/xhtml" xmlns:splunk="http://www.splunk.com/xhtml-extensions/1.0" xml:lang="en"&amp;gt;
   &amp;lt;head&amp;gt;
  &amp;lt;meta http-equiv="content-type" content="text/html; charset=utf-8" /&amp;gt;
  &amp;lt;link rel="shortcut icon" href="/en-
  US/static/@EA9E3236A0BA7C4B28247E726C3C7D69A561FB26DFC20737824C1922C733518A/img/favicon.ico" /&amp;gt;
 &amp;lt;title&amp;gt;Splunk cannot authenticate the request. CSRF validation failed. - Splunk&amp;lt;/title&amp;gt;
 &amp;lt;style&amp;gt;
     *       { margin: 0; padding: 0; }
    body    { font-family: helvetica, arial, sans-serif; color: #333; padding: 20px; }
    p,pre   { margin-bottom: 1em; font-size: .8em; }
    .status { font-size: .7em; color: #999; margin-bottom: 1em; }
    .msg    { margin-bottom: 1em; font-size: 1.4em;}
    pre     { font-family: Monaco,Courier Bold,Courier New,monospace; font-size: .7em;background-color: #eee;  padding: 5px;}
    #toggle { font-size: .8em; margin-bottom: 1em; }
    .byline { color: #555; }
    .byline span { font-weight: bold; line-height: 1.4em; }
    hr      { height: 1px; background-color: #ccc; border: 0; margin: 20px 0 10px; }
    h2      { font-size: 1em; margin-bottom: 1em; }
    table   { border-collapse: collapse; }
    td      { padding: 2px; }
    td.k    { font-family: helvetica, arial, sans-serif; font-weight: bold; }
    #debug  { display: none; }
    #crashes { margin: 20px 0; padding: 10px; border: 1px solid #800; }
    #crashes dt { font-size: 12px; margin-bottom: 5px; }
    #crashes dd { white-space: pre; background: #f2f2f2; padding: 10px; margin-left: 20px; display: none; font: 10px Monaco,Courier Bold,Courier New,monospace; }
&amp;lt;/style&amp;gt;
&amp;lt;script&amp;gt;
    function toggle(what) {
        what = document.getElementById(what);
        if (what.style.display == 'block') {
            what.style.display = 'none';
        } else {
            what.style.display = 'block';
        }
    }
&amp;lt;/script&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
   &amp;lt;p class="status"&amp;gt;401 Unauthorized&amp;lt;/p&amp;gt;
   &amp;lt;p class="homelink"&amp;gt;&amp;lt;a href="/"&amp;gt;Return to Splunk home page&amp;lt;/a&amp;gt;&amp;lt;/p&amp;gt;
    &amp;lt;h1 class="msg"&amp;gt;Splunk cannot authenticate the request. CSRF validation failed.&amp;lt;/h1&amp;gt;
      &amp;lt;a href="/en-US/app/search/search?q=index%3D_internal%20host%3D%22xxx%22%20source%3D%2Aweb_service.log%20log_level%3DERROR%20requestid%3D5c1a06af277fdd04614990" target="_blank"&amp;gt;View more information about your request (request ID = 5c1a06af277fdd04614990) in 
   Search&amp;lt;/a&amp;gt;
    &amp;amp;lt;br/&amp;amp;gt;
   &amp;amp;lt;br/&amp;amp;gt;
  &amp;amp;lt;br/&amp;amp;gt;
 &amp;lt;hr /&amp;gt;
 &amp;lt;p class="byline"&amp;gt;You are using &amp;lt;span&amp;gt;xxxx.xxxxx.com:8000&amp;lt;/span&amp;gt;, which is connected to splunkd 
&amp;lt;span&amp;gt;@59c8927def0f&amp;lt;/span&amp;gt; at &amp;lt;span&amp;gt;https://127.0.0.1:8089&amp;lt;/span&amp;gt; on &amp;lt;span&amp;gt;Wed Dec 19 03:51:59 2018&amp;lt;/span&amp;gt;.&amp;lt;/p&amp;gt;
 &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;I'm able to get the session key with same credentials :-&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;curl -k &lt;A href="http://host.domain.com:8000/en-US/splunkd/services/auth/login" target="test_blank"&gt;http://host.domain.com:8000/en-US/splunkd/services/auth/login&lt;/A&gt; --data-urlencode username=user--data-urlencode password=pass

&amp;lt;response&amp;gt;
 &amp;lt;sessionKey&amp;gt;yATMHjpws9MOIGi5Rg9QvsoRR4EMncSGxlerJ9W6B....&amp;lt;/sessionKey&amp;gt;
&amp;lt;/response&amp;gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Please suggest. Apologies for the editing, I'm new at this.&lt;/P&gt;

&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 09:04:46 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-come-our-Splunk-6-5-REST-API-calls-with-curl-command-are-not/m-p/440934#M76854</guid>
      <dc:creator>mukesh2019</dc:creator>
      <dc:date>2018-12-19T09:04:46Z</dc:date>
    </item>
    <item>
      <title>Re: How come our Splunk 6.5 REST API calls with curl command are not working?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-come-our-Splunk-6-5-REST-API-calls-with-curl-command-are-not/m-p/440935#M76855</link>
      <description>&lt;P&gt;Hello @mukesh2019,&lt;/P&gt;

&lt;P&gt;You are using the wrong port.&lt;/P&gt;

&lt;P&gt;Splunk's management port is &lt;STRONG&gt;8089&lt;/STRONG&gt;. You also need to use &lt;STRONG&gt;https&lt;/STRONG&gt; instead of http.&lt;/P&gt;

&lt;P&gt;Also remove the language modifier. It should look like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&lt;A href="https://host.domain.com:8089/services/search/jobs" target="test_blank"&gt;https://host.domain.com:8089/services/search/jobs&lt;/A&gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Check out the &lt;A href="http://dev.splunk.com/restapi"&gt;REST API documentation&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 12:33:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-come-our-Splunk-6-5-REST-API-calls-with-curl-command-are-not/m-p/440935#M76855</guid>
      <dc:creator>whrg</dc:creator>
      <dc:date>2018-12-19T12:33:56Z</dc:date>
    </item>
    <item>
      <title>Re: How come our Splunk 6.5 REST API calls with curl command are not working?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/How-come-our-Splunk-6-5-REST-API-calls-with-curl-command-are-not/m-p/440936#M76856</link>
      <description>&lt;P&gt;Thanks a lot &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Dec 2018 15:12:47 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/How-come-our-Splunk-6-5-REST-API-calls-with-curl-command-are-not/m-p/440936#M76856</guid>
      <dc:creator>mukesh2019</dc:creator>
      <dc:date>2018-12-19T15:12:47Z</dc:date>
    </item>
  </channel>
</rss>

