<?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 get data from splunk with REST API? in Splunk Enterprise</title>
    <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-get-data-from-splunk-with-REST-API/m-p/754712#M23325</link>
    <description>&lt;P&gt;Nice!&lt;BR /&gt;&lt;BR /&gt;Actually in my response I meant POST, but I ended up typing GET as in my mind I was still thinking about the fact that you were sending GET without knowing... Forgive me, I should have double checked my code &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;This issue that you mentioned, "&lt;SPAN&gt;Failed to load resource: net::ERR_CERT_AUTHORITY_INVALID", refers to specific certificate validation issues. Most likely your instance is using self signed certs, so REACT will find those and hit those cert authority issues just to protect the client as we see for example in the browser when you are trying to do the same.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Unfortunately there is no way around it like skipping the verification for REACT, but if you install a trusted certificate in your Splunk instance this won't be a problem anymore.&lt;BR /&gt;Just saying, as you may want to consider that in the future.&lt;BR /&gt;&lt;BR /&gt;For now, as you got it working with the lib directly, go for it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 24 Oct 2025 13:01:45 GMT</pubDate>
    <dc:creator>victor_menezes</dc:creator>
    <dc:date>2025-10-24T13:01:45Z</dc:date>
    <item>
      <title>How to get data from splunk with REST API?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-get-data-from-splunk-with-REST-API/m-p/754572#M23299</link>
      <description>&lt;P&gt;Hey together,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to fetch data from splunk via REST API in a react application.&lt;/P&gt;&lt;P&gt;When I try to create a search job with this code (You can try this code in the console of your browser in the splunk web!):&lt;BR /&gt;&lt;BR /&gt;fetch('/splunkd/services/search/jobs', {&lt;BR /&gt;credentials: 'include',&lt;BR /&gt;method: 'POST',&lt;BR /&gt;headers: new Headers({&lt;BR /&gt;'Content-Type': 'application/x-www-form-urlencoded'&lt;BR /&gt;}),&lt;BR /&gt;body: new URLSearchParams({&lt;BR /&gt;'search': 'search |makeresults 2',&lt;BR /&gt;'output_mode': 'json'&lt;BR /&gt;}),&lt;BR /&gt;redirect: 'follow'&lt;BR /&gt;}).then((res) =&amp;gt; res.text()).then((data) =&amp;gt; console.log(data))&lt;BR /&gt;&lt;BR /&gt;I'm getting all the search jobs who are currently running. When I'm looking in the REST API for&amp;nbsp;/splunkd/services/search/jobs I would expect that the response is a sid of the the new search job.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I tried it with postman and there I get a response I expect like:&lt;BR /&gt;{&lt;BR /&gt;&amp;nbsp; &amp;nbsp;"sid":&amp;nbsp; "123456789.123"&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;What ever I try I doesnt work. What am I missing? I also set X-Splunk-Form-Key and X-Requested-With. Still doesnt work.&lt;BR /&gt;Is there a difference using /splunkd or &lt;A href="https://localhost...?" target="_blank" rel="noopener"&gt;https://localhost...?&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;I know there are libaries with creatSearchJob() and getData(). They worked, but couldnt use it well with Query react.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Oct 2025 13:25:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-get-data-from-splunk-with-REST-API/m-p/754572#M23299</guid>
      <dc:creator>Janis</dc:creator>
      <dc:date>2025-10-22T13:25:57Z</dc:date>
    </item>
    <item>
      <title>Re: How to get data from splunk with REST API?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-get-data-from-splunk-with-REST-API/m-p/754578#M23303</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/313746"&gt;@Janis&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;That may happen because your code is somehow passing it as GET instead of POST (though I see the POST method there, it may not being interpreted as you want. Also, your search string is invalid. See, you are passing it as "search | makeresults 2", so search command is getting makeresults to be interpreted as a search string instead of a command.&lt;BR /&gt;&lt;BR /&gt;Try to execute with the search string as simple as "| makeresults count=2"&lt;BR /&gt;&lt;BR /&gt;Ideally, try via REST Url/port instead of splunkd. Not that it doesn't work fine there, but using Rest is easier to manage/debug IMO.&lt;BR /&gt;&lt;BR /&gt;So, what about something like this:&lt;BR /&gt;const options = {&lt;BR /&gt;method: 'GET',&lt;BR /&gt;headers: {&lt;BR /&gt;'Content-Type': 'application/x-www-form-urlencoded',&lt;BR /&gt;Authorization: 'Basic &amp;lt;your_auth&amp;gt;'&lt;BR /&gt;},&lt;BR /&gt;body: new URLSearchParams({search: '| makeresults count=2', output_mode: 'json'})&lt;BR /&gt;};&lt;/P&gt;&lt;P&gt;fetch('https://&amp;lt;your_host&amp;gt;:&amp;lt;your_rest_port&amp;gt;/services/search/jobs', options)&lt;BR /&gt;.then(response =&amp;gt; response.json())&lt;BR /&gt;.then(response =&amp;gt; console.log(response))&lt;BR /&gt;.catch(err =&amp;gt; console.error(err));&lt;/P&gt;</description>
      <pubDate>Wed, 22 Oct 2025 19:05:56 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-get-data-from-splunk-with-REST-API/m-p/754578#M23303</guid>
      <dc:creator>victor_menezes</dc:creator>
      <dc:date>2025-10-22T19:05:56Z</dc:date>
    </item>
    <item>
      <title>Re: How to get data from splunk with REST API?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-get-data-from-splunk-with-REST-API/m-p/754599#M23306</link>
      <description>&lt;P&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/313746"&gt;@Janis&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Can you try with management port&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;https://localhost:8089/services/search/jobs?output_mode=json&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;and basic authentication&lt;/P&gt;&lt;P&gt;Regards,&lt;BR /&gt;Prewin&lt;BR /&gt;If this answer helped you, please consider marking it as the solution or giving a Karma. Thanks!&lt;/P&gt;</description>
      <pubDate>Thu, 23 Oct 2025 04:24:34 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-get-data-from-splunk-with-REST-API/m-p/754599#M23306</guid>
      <dc:creator>PrewinThomas</dc:creator>
      <dc:date>2025-10-23T04:24:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to get data from splunk with REST API?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-get-data-from-splunk-with-REST-API/m-p/754690#M23319</link>
      <description>&lt;P&gt;I tried it but I get the error: "Failed to load resource: net::ERR_CERT_AUTHORITY_INVALID"&lt;BR /&gt;But this Problem seems to be a CORS-problem because I dont setup the certifications.&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;I think in a production enviroment I can't manage this even I will get this to work, so I will try something else (see other response)&lt;/P&gt;</description>
      <pubDate>Fri, 24 Oct 2025 09:57:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-get-data-from-splunk-with-REST-API/m-p/754690#M23319</guid>
      <dc:creator>Janis</dc:creator>
      <dc:date>2025-10-24T09:57:30Z</dc:date>
    </item>
    <item>
      <title>Re: How to get data from splunk with REST API?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-get-data-from-splunk-with-REST-API/m-p/754693#M23320</link>
      <description>&lt;P&gt;Yeah, I looks like it send only a GET request, because the answer are the current search jobs.&amp;nbsp;&lt;BR /&gt;Your code dont work, because a GET method dont accept a body, I also tried with POST, but same problem like in PrewinThomas answer.&lt;BR /&gt;&lt;BR /&gt;So I tried the libary&amp;nbsp;&lt;SPAN&gt;&lt;a href="https://community.splunk.com/t5/user/viewprofilepage/user-id/149"&gt;@splunk&lt;/a&gt;&lt;/SPAN&gt;&lt;SPAN class=""&gt;/&lt;/SPAN&gt;&lt;SPAN&gt;splunk&lt;/SPAN&gt;&lt;SPAN class=""&gt;-&lt;/SPAN&gt;&lt;SPAN&gt;utils/search. And do a createSearchJob(). Then I looked in the dev-tools and got this Request. I modified it a bit :&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;fetch('http://127.0.0.1:8000/de-DE/splunkd/__raw/services/search/jobs', {
    headers: {
        'content-type': 'application/x-www-form-urlencoded',
        'x-requested-with': 'XMLHttpRequest',
        'x-splunk-form-key': '&amp;lt;YOUR_KEY&amp;gt;',
    },
    body: new URLSearchParams({
        search: 'search | makeresults 2',
        output_mode: 'json',
    }),
    method: 'POST',
})
    .then((r) =&amp;gt; r.json())
    .then((data) =&amp;gt; console.log(data));&lt;/LI-CODE&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;And this work! Anyways I guess I will first stick to the libary. Maybe later I can improve fetching the data.&lt;BR /&gt;&lt;BR /&gt;Here I get the request e.g. as fetch(). The&amp;nbsp;x-splunk-form-key you can find other the cookies "splunkweb_csrf_token_8000".&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Janis_1-1761300801298.png" style="width: 400px;"&gt;&lt;img src="https://community.splunk.com/t5/image/serverpage/image-id/40652iC4AFA92368A306DB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Janis_1-1761300801298.png" alt="Janis_1-1761300801298.png" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Janis_1-1761300801298.png&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Oct 2025 10:19:12 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-get-data-from-splunk-with-REST-API/m-p/754693#M23320</guid>
      <dc:creator>Janis</dc:creator>
      <dc:date>2025-10-24T10:19:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to get data from splunk with REST API?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-get-data-from-splunk-with-REST-API/m-p/754712#M23325</link>
      <description>&lt;P&gt;Nice!&lt;BR /&gt;&lt;BR /&gt;Actually in my response I meant POST, but I ended up typing GET as in my mind I was still thinking about the fact that you were sending GET without knowing... Forgive me, I should have double checked my code &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;&lt;BR /&gt;This issue that you mentioned, "&lt;SPAN&gt;Failed to load resource: net::ERR_CERT_AUTHORITY_INVALID", refers to specific certificate validation issues. Most likely your instance is using self signed certs, so REACT will find those and hit those cert authority issues just to protect the client as we see for example in the browser when you are trying to do the same.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Unfortunately there is no way around it like skipping the verification for REACT, but if you install a trusted certificate in your Splunk instance this won't be a problem anymore.&lt;BR /&gt;Just saying, as you may want to consider that in the future.&lt;BR /&gt;&lt;BR /&gt;For now, as you got it working with the lib directly, go for it &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Oct 2025 13:01:45 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-get-data-from-splunk-with-REST-API/m-p/754712#M23325</guid>
      <dc:creator>victor_menezes</dc:creator>
      <dc:date>2025-10-24T13:01:45Z</dc:date>
    </item>
    <item>
      <title>Re: How to get data from splunk with REST API?</title>
      <link>https://community.splunk.com/t5/Splunk-Enterprise/How-to-get-data-from-splunk-with-REST-API/m-p/754767#M23335</link>
      <description>&lt;P&gt;Thanks for the advice! I will keep that in mind, when I try it again.&amp;nbsp;&lt;BR /&gt;Now I will focus on the application and play with data and visualization&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":raising_hands:"&gt;🙌&lt;/span&gt;.&lt;/P&gt;&lt;P&gt;See You!&lt;/P&gt;</description>
      <pubDate>Mon, 27 Oct 2025 06:36:59 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Enterprise/How-to-get-data-from-splunk-with-REST-API/m-p/754767#M23335</guid>
      <dc:creator>Janis</dc:creator>
      <dc:date>2025-10-27T06:36:59Z</dc:date>
    </item>
  </channel>
</rss>

