<?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 to call Splunk custom endpoint using jquery ? in Splunk Search</title>
    <link>https://community.splunk.com/t5/Splunk-Search/How-to-call-Splunk-custom-endpoint-using-jquery/m-p/396219#M173713</link>
    <description>&lt;P&gt;Dear all,&lt;/P&gt;

&lt;P&gt;I wish I could make a call such as $.ajax(...) to my custom endpoint.&lt;/P&gt;

&lt;P&gt;But which Splunk method should I use to automatically build the URI ? If I provide "/services/mycustomendpoint", it won't work as it depends on the app URI for example. But I wish I could avoid adding manually the app URI and other prefixes.&lt;/P&gt;

&lt;P&gt;Which Splunk library should I use to get that URI from the context?&lt;/P&gt;

&lt;P&gt;Thank you,&lt;/P&gt;</description>
    <pubDate>Thu, 10 Jan 2019 19:32:32 GMT</pubDate>
    <dc:creator>ecoquelin</dc:creator>
    <dc:date>2019-01-10T19:32:32Z</dc:date>
    <item>
      <title>How to call Splunk custom endpoint using jquery ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-call-Splunk-custom-endpoint-using-jquery/m-p/396219#M173713</link>
      <description>&lt;P&gt;Dear all,&lt;/P&gt;

&lt;P&gt;I wish I could make a call such as $.ajax(...) to my custom endpoint.&lt;/P&gt;

&lt;P&gt;But which Splunk method should I use to automatically build the URI ? If I provide "/services/mycustomendpoint", it won't work as it depends on the app URI for example. But I wish I could avoid adding manually the app URI and other prefixes.&lt;/P&gt;

&lt;P&gt;Which Splunk library should I use to get that URI from the context?&lt;/P&gt;

&lt;P&gt;Thank you,&lt;/P&gt;</description>
      <pubDate>Thu, 10 Jan 2019 19:32:32 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-call-Splunk-custom-endpoint-using-jquery/m-p/396219#M173713</guid>
      <dc:creator>ecoquelin</dc:creator>
      <dc:date>2019-01-10T19:32:32Z</dc:date>
    </item>
    <item>
      <title>Re: How to call Splunk custom endpoint using jquery ?</title>
      <link>https://community.splunk.com/t5/Splunk-Search/How-to-call-Splunk-custom-endpoint-using-jquery/m-p/396220#M173714</link>
      <description>&lt;P&gt;The REST endpoints under "/services" are not app-specific even though you put them you &lt;CODE&gt;$SPLUNK_HOME/etc/apps/yourapp/bin&lt;/CODE&gt;, and they go via Splunk management port (8089 by default). This is somewhat of a problem - while your browser normally connects to &lt;CODE&gt;&lt;A href="http://yoursplunkhost:8000/en-US/app/yourapp" target="test_blank"&gt;http://yoursplunkhost:8000/en-US/app/yourapp&lt;/A&gt;&lt;/CODE&gt;, REST API calls go to &lt;CODE&gt;&lt;A href="https://yoursplunkhost:8089/services/yourcustomendpoint" target="test_blank"&gt;https://yoursplunkhost:8089/services/yourcustomendpoint&lt;/A&gt;&lt;/CODE&gt;. This creates CORS problems unless you properly set HTTP headers in your custom endpoint. And it normally needs authentication, unless you set &lt;CODE&gt;requireAuthentication = false&lt;/CODE&gt; in the endpoint's stanza in &lt;CODE&gt;restmap.conf&lt;/CODE&gt;.&lt;/P&gt;

&lt;P&gt;There is another way of creating custom endpoints - putting the scripts not in &lt;CODE&gt;$SPLUNK_HOME/etc/apps/yourapp/bin&lt;/CODE&gt;, but in &lt;CODE&gt;$SPLUNK_HOME/etc/apps/yourapp/appserver/controllers&lt;/CODE&gt; and defining it in &lt;CODE&gt;$SPLUNK_HOME/etc/apps/yourapp/default/web.conf&lt;/CODE&gt;. This one goes through &lt;CODE&gt;&lt;A href="http://yoursplunkhost:8080/en-US/custom/yourapp/yourcustomendpoint" target="test_blank"&gt;http://yoursplunkhost:8080/en-US/custom/yourapp/yourcustomendpoint&lt;/A&gt;&lt;/CODE&gt; and picks up the authentication of your browser page IIRC, but you'd better check the exact ways in the documentation.&lt;/P&gt;</description>
      <pubDate>Fri, 11 Jan 2019 17:16:23 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Splunk-Search/How-to-call-Splunk-custom-endpoint-using-jquery/m-p/396220#M173714</guid>
      <dc:creator>arkadyz1</dc:creator>
      <dc:date>2019-01-11T17:16:23Z</dc:date>
    </item>
  </channel>
</rss>

