<?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 do you access the custom endpoint from dashboard javascript? in Dashboards &amp; Visualizations</title>
    <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-you-access-the-custom-endpoint-from-dashboard-javascript/m-p/382578#M25077</link>
    <description>&lt;P&gt;seems that you are mixing Get and Post.&lt;/P&gt;

&lt;P&gt;try:&lt;/P&gt;

&lt;P&gt;web.xml:&lt;BR /&gt;
     methods=POST,GET&lt;/P&gt;

&lt;P&gt;my_submit.py:&lt;BR /&gt;
    handle_GET = handle_POST = handle_submit    &lt;/P&gt;

&lt;P&gt;and try both js methods:&lt;BR /&gt;
service.post(...) and service.get(...)&lt;/P&gt;</description>
    <pubDate>Tue, 29 Sep 2020 21:58:08 GMT</pubDate>
    <dc:creator>lweber</dc:creator>
    <dc:date>2020-09-29T21:58:08Z</dc:date>
    <item>
      <title>How do you access the custom endpoint from dashboard javascript?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-you-access-the-custom-endpoint-from-dashboard-javascript/m-p/382577#M25076</link>
      <description>&lt;P&gt;I  have configured my REST API custom endpoint within a new app, and tested successfully through the service web's UI (:8089). But got 404 from javascript. Splunk version: 7.2.0, User account has admin role:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;service.post('services/my_submit', data, function...
&lt;A href="http://mysplunk:8000/en-US/splunkd/__raw/services/my_submit?output_mode=json" target="test_blank"&gt;http://mysplunk:8000/en-US/splunkd/__raw/services/my_submit?output_mode=json&lt;/A&gt; 404 (Not Found)
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Accessing from service port prints 'success' from the python script:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;&lt;A href="https://mysplunk:8089/services/my_submit" target="test_blank"&gt;https://mysplunk:8089/services/my_submit&lt;/A&gt;
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;web.xml: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[expose:my_submit]
pattern=my_submit
methods=POST
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;restmap.conf: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;[script:my_submit]
match=/my_submit
handler=my_submit.Submit
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;my_submit.py: &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;import splunk
class Submit(splunk.rest.BaseRestHandler):
    def handle_submit(self):
        try:
            self.response.setHeader('content-type', 'text/html')
            self.response.write('success')
        except:
            self.response.setHeader('content-type', 'text/html')
            self.response.write('&amp;lt;p&amp;gt;Uh oh! Something wrong!&amp;lt;/p&amp;gt;')

    handle_GET = handle_submit    
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;Should I use 'services/my_submit' as the endpoint in the service call? What else could I miss?  Your help is greatly appreciated.&lt;BR /&gt;
Tony&lt;/P&gt;</description>
      <pubDate>Mon, 12 Nov 2018 14:47:05 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-you-access-the-custom-endpoint-from-dashboard-javascript/m-p/382577#M25076</guid>
      <dc:creator>Dev999</dc:creator>
      <dc:date>2018-11-12T14:47:05Z</dc:date>
    </item>
    <item>
      <title>Re: How do you access the custom endpoint from dashboard javascript?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-you-access-the-custom-endpoint-from-dashboard-javascript/m-p/382578#M25077</link>
      <description>&lt;P&gt;seems that you are mixing Get and Post.&lt;/P&gt;

&lt;P&gt;try:&lt;/P&gt;

&lt;P&gt;web.xml:&lt;BR /&gt;
     methods=POST,GET&lt;/P&gt;

&lt;P&gt;my_submit.py:&lt;BR /&gt;
    handle_GET = handle_POST = handle_submit    &lt;/P&gt;

&lt;P&gt;and try both js methods:&lt;BR /&gt;
service.post(...) and service.get(...)&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 21:58:08 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-you-access-the-custom-endpoint-from-dashboard-javascript/m-p/382578#M25077</guid>
      <dc:creator>lweber</dc:creator>
      <dc:date>2020-09-29T21:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: How do you access the custom endpoint from dashboard javascript?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-you-access-the-custom-endpoint-from-dashboard-javascript/m-p/382579#M25078</link>
      <description>&lt;P&gt;Thanks lweber. I can see missing handle_POST in python would be a problem.  If I replace handle_GET with handle_POST only, I got a specific python error (object has no attribute 'handle_GET' ) on port 8089 web. Now I have both as you suggested, and added to web.xml, but still gets 404 error regardless I do service.get or service.post. I can do curl with -XPOST to get the correct response from port 8089.&lt;/P&gt;</description>
      <pubDate>Tue, 29 Sep 2020 22:00:55 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-you-access-the-custom-endpoint-from-dashboard-javascript/m-p/382579#M25078</guid>
      <dc:creator>Dev999</dc:creator>
      <dc:date>2020-09-29T22:00:55Z</dc:date>
    </item>
    <item>
      <title>Re: How do you access the custom endpoint from dashboard javascript?</title>
      <link>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-you-access-the-custom-endpoint-from-dashboard-javascript/m-p/382580#M25079</link>
      <description>&lt;P&gt;After correcting GET/POST, I realized the problem was that the file name should be web.conf, not web.xml. &lt;/P&gt;</description>
      <pubDate>Mon, 12 Nov 2018 20:28:18 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Dashboards-Visualizations/How-do-you-access-the-custom-endpoint-from-dashboard-javascript/m-p/382580#M25079</guid>
      <dc:creator>Dev999</dc:creator>
      <dc:date>2018-11-12T20:28:18Z</dc:date>
    </item>
  </channel>
</rss>

