<?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: access custom Rest endpoint using javascript in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/access-custom-Rest-endpoint-using-javascript/m-p/122258#M7153</link>
    <description>&lt;P&gt;Hi lweber-&lt;BR /&gt;
I know this is VERY old, but could you point me to some python code or maybe some of your code that can show me more how you accessed the endpoint in the script?  I am trying to create an app that will allow an admin to do REST calls within a dashboard that would normally take forever in GUI (and are not always convenient to do on the CLI - like mass job deletes, mass saved search updates, mass ID changes, etc). &lt;/P&gt;

&lt;P&gt;Thanks!&lt;BR /&gt;
Mike &lt;/P&gt;</description>
    <pubDate>Wed, 17 May 2017 00:10:41 GMT</pubDate>
    <dc:creator>atari1050</dc:creator>
    <dc:date>2017-05-17T00:10:41Z</dc:date>
    <item>
      <title>access custom Rest endpoint using javascript</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/access-custom-Rest-endpoint-using-javascript/m-p/122253#M7148</link>
      <description>&lt;P&gt;my restmap.conf looks like this:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[script:testrest]
match=/mytest
scripttype=python
handler=testhandler.MyHandler
output_modes=json
requireAuthentication=true
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Accessing it with curl works like a charm. &lt;BR /&gt;
But how can I fire a call to it from within a Splunk dashboard (using javascript)?&lt;/P&gt;

&lt;P&gt;I tried something like:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;var service = mvc.createService();
service.get("/mytest")
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;what obviously doesnt work...&lt;/P&gt;

&lt;P&gt;&lt;STRONG&gt;Edit:&lt;/STRONG&gt;&lt;BR /&gt;
seems nobody can give me a hint, let me ask my question in a different way:&lt;BR /&gt;
How can i tell Splunk to expose my REST endpoint under: &lt;A href="http://127.0.0.1:8000/en-US/splunkd/__raw/mytest"&gt;http://127.0.0.1:8000/en-US/splunkd/__raw/mytest&lt;/A&gt;?&lt;/P&gt;

&lt;P&gt;or more general:&lt;BR /&gt;
How can i run (custom) server side code from within a dashboard using javascript?&lt;/P&gt;

&lt;P&gt;Hope this helps to get into the right direction&lt;/P&gt;</description>
      <pubDate>Mon, 25 May 2015 15:42:09 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/access-custom-Rest-endpoint-using-javascript/m-p/122253#M7148</guid>
      <dc:creator>lweber</dc:creator>
      <dc:date>2015-05-25T15:42:09Z</dc:date>
    </item>
    <item>
      <title>Re: access custom Rest endpoint using javascript</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/access-custom-Rest-endpoint-using-javascript/m-p/122254#M7149</link>
      <description>&lt;P&gt;ok. found the solution myself...&lt;/P&gt;

&lt;P&gt;I had to add the following in my web.conf:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[expose:testrest]
pattern=mytest
methods=GET,POST,DELETE
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;now i can access it in js with:&lt;BR /&gt;
&lt;CODE&gt;service.get("/services/mytest")&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 26 May 2015 11:01:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/access-custom-Rest-endpoint-using-javascript/m-p/122254#M7149</guid>
      <dc:creator>lweber</dc:creator>
      <dc:date>2015-05-26T11:01:21Z</dc:date>
    </item>
    <item>
      <title>Re: access custom Rest endpoint using javascript</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/access-custom-Rest-endpoint-using-javascript/m-p/122255#M7150</link>
      <description>&lt;P&gt;where did you link this end point to your python code ?  in restmap.conf ?&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2015 09:41:21 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/access-custom-Rest-endpoint-using-javascript/m-p/122255#M7150</guid>
      <dc:creator>i2sheri</dc:creator>
      <dc:date>2015-11-25T09:41:21Z</dc:date>
    </item>
    <item>
      <title>Re: access custom Rest endpoint using javascript</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/access-custom-Rest-endpoint-using-javascript/m-p/122256#M7151</link>
      <description>&lt;P&gt;yes, restmap.conf:&lt;/P&gt;

&lt;P&gt;[script:testrest]&lt;BR /&gt;
match=/mytest&lt;BR /&gt;
scripttype=python&lt;BR /&gt;
handler=myscript.MyClass&lt;BR /&gt;
output_modes=json&lt;BR /&gt;
requireAuthentication=true&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2015 10:09:30 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/access-custom-Rest-endpoint-using-javascript/m-p/122256#M7151</guid>
      <dc:creator>lweber</dc:creator>
      <dc:date>2015-11-25T10:09:30Z</dc:date>
    </item>
    <item>
      <title>Re: access custom Rest endpoint using javascript</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/access-custom-Rest-endpoint-using-javascript/m-p/122257#M7152</link>
      <description>&lt;P&gt;thanks, works with 6.3.&lt;BR /&gt;
I can use this solution to get rid of frame work app, which does not work with requireClientCert=true and is deprecated now.&lt;/P&gt;</description>
      <pubDate>Thu, 26 Nov 2015 03:56:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/access-custom-Rest-endpoint-using-javascript/m-p/122257#M7152</guid>
      <dc:creator>i2sheri</dc:creator>
      <dc:date>2015-11-26T03:56:18Z</dc:date>
    </item>
    <item>
      <title>Re: access custom Rest endpoint using javascript</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/access-custom-Rest-endpoint-using-javascript/m-p/122258#M7153</link>
      <description>&lt;P&gt;Hi lweber-&lt;BR /&gt;
I know this is VERY old, but could you point me to some python code or maybe some of your code that can show me more how you accessed the endpoint in the script?  I am trying to create an app that will allow an admin to do REST calls within a dashboard that would normally take forever in GUI (and are not always convenient to do on the CLI - like mass job deletes, mass saved search updates, mass ID changes, etc). &lt;/P&gt;

&lt;P&gt;Thanks!&lt;BR /&gt;
Mike &lt;/P&gt;</description>
      <pubDate>Wed, 17 May 2017 00:10:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/access-custom-Rest-endpoint-using-javascript/m-p/122258#M7153</guid>
      <dc:creator>atari1050</dc:creator>
      <dc:date>2017-05-17T00:10:41Z</dc:date>
    </item>
    <item>
      <title>Re: access custom Rest endpoint using javascript</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/access-custom-Rest-endpoint-using-javascript/m-p/122259#M7154</link>
      <description>&lt;P&gt;I made essentially the exactly same setup in a new app, but I got 404 error when calling service.post('services/myendpoint', ). I am using Splunk 7.2.0.  Could you please take a look at my question:&lt;/P&gt;

&lt;P&gt;&lt;A href="https://answers.splunk.com/answers/699676/accessing-custom-endpoint-from-dashboard-javascrip.html"&gt;https://answers.splunk.com/answers/699676/accessing-custom-endpoint-from-dashboard-javascrip.html&lt;/A&gt;&lt;/P&gt;

&lt;P&gt;Thanks,&lt;BR /&gt;
Tony&lt;/P&gt;</description>
      <pubDate>Mon, 12 Nov 2018 14:52:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/access-custom-Rest-endpoint-using-javascript/m-p/122259#M7154</guid>
      <dc:creator>Dev999</dc:creator>
      <dc:date>2018-11-12T14:52:22Z</dc:date>
    </item>
    <item>
      <title>Re: access custom Rest endpoint using javascript</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/access-custom-Rest-endpoint-using-javascript/m-p/530754#M36064</link>
      <description>&lt;P&gt;The web.conf addition was exactly what I was missing. I originally copied it from another app (using it to learn how to build a custom rest handler). I would then test using port 8089 but couldn't get it to work from 443 (Splunk web). I kept thinking restmap.conf was the only file I had to update.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 05:54:10 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/access-custom-Rest-endpoint-using-javascript/m-p/530754#M36064</guid>
      <dc:creator>tmontney</dc:creator>
      <dc:date>2020-11-25T05:54:10Z</dc:date>
    </item>
  </channel>
</rss>

