<?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: Is it possible to set a custom HTTP response header from a custom API endpoint? in Getting Data In</title>
    <link>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-set-a-custom-HTTP-response-header-from-a/m-p/278541#M53322</link>
    <description>&lt;P&gt;I've done it and did set at least Access-Control-Allow-Origin with no problem.&lt;/P&gt;</description>
    <pubDate>Fri, 21 Apr 2017 19:38:33 GMT</pubDate>
    <dc:creator>arkadyz1</dc:creator>
    <dc:date>2017-04-21T19:38:33Z</dc:date>
    <item>
      <title>Is it possible to set a custom HTTP response header from a custom API endpoint?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-set-a-custom-HTTP-response-header-from-a/m-p/278540#M53321</link>
      <description>&lt;P&gt;Given a Splunk Enterprise instance, we'd like to implement a custom API handler that also sets the CORS headers in the response:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;Access-Control-Allow-Origin: &lt;A href="http://…" target="test_blank"&gt;http://…&lt;/A&gt;
Access-Control-Allow-Credentials: true
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The goal is to allow a cloud service, with a customer's consent as expressed by installing the custom application AND providing the URL for their Splunk Enterprise instance, to perform a specific search via the custom REST API endpoint handler.&lt;/P&gt;

&lt;P&gt;Before we start to dig into it, is there anything in place to prevent or disallow this?  Has anyone done this and have any tips?&lt;/P&gt;</description>
      <pubDate>Sat, 04 Feb 2017 01:35:41 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-set-a-custom-HTTP-response-header-from-a/m-p/278540#M53321</guid>
      <dc:creator>plambert</dc:creator>
      <dc:date>2017-02-04T01:35:41Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to set a custom HTTP response header from a custom API endpoint?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-set-a-custom-HTTP-response-header-from-a/m-p/278541#M53322</link>
      <description>&lt;P&gt;I've done it and did set at least Access-Control-Allow-Origin with no problem.&lt;/P&gt;</description>
      <pubDate>Fri, 21 Apr 2017 19:38:33 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-set-a-custom-HTTP-response-header-from-a/m-p/278541#M53322</guid>
      <dc:creator>arkadyz1</dc:creator>
      <dc:date>2017-04-21T19:38:33Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to set a custom HTTP response header from a custom API endpoint?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-set-a-custom-HTTP-response-header-from-a/m-p/278542#M53323</link>
      <description>&lt;P&gt;The doc to implement custom end points in splunk is available &lt;A href="http://wiki.splunk.com/Community:40GUIDevelopment"&gt;here&lt;/A&gt;,&lt;BR /&gt;
Just python implementation..&lt;/P&gt;

&lt;P&gt;It internally uses cherrypy, you can set header by &lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;cherrypy.response.headers['Content-Type'] = 'application/json'
&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 24 Apr 2017 12:23:57 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-set-a-custom-HTTP-response-header-from-a/m-p/278542#M53323</guid>
      <dc:creator>paramagurukarth</dc:creator>
      <dc:date>2017-04-24T12:23:57Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to set a custom HTTP response header from a custom API endpoint?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-set-a-custom-HTTP-response-header-from-a/m-p/278543#M53324</link>
      <description>&lt;P&gt;Could you give and example, I can´t figure it out. I'm getting No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin '&lt;A href="http://localhost:8000"&gt;http://localhost:8000&lt;/A&gt;' is therefore not allowed access.&lt;/P&gt;</description>
      <pubDate>Fri, 18 May 2018 17:31:52 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-set-a-custom-HTTP-response-header-from-a/m-p/278543#M53324</guid>
      <dc:creator>marcolesh</dc:creator>
      <dc:date>2018-05-18T17:31:52Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to set a custom HTTP response header from a custom API endpoint?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-set-a-custom-HTTP-response-header-from-a/m-p/278544#M53325</link>
      <description>&lt;P&gt;How is your API organized? It can be added in more than one way: when I wrote my response, we were adding exta REST API endpoints via etc/system/local/restmap.conf - this makes them accessible through the &lt;STRONG&gt;management&lt;/STRONG&gt; port (8089 by default). There you just add your header to the response:&lt;/P&gt;

&lt;PRE&gt;&lt;CODE&gt;class YourOwnAPIHandler(splunk.rest.BaseRestHandler):
    def handle_POST(self):

      ...
      self.response.setHeader('access-control-allow-origin', '*')
      return
&lt;/CODE&gt;&lt;/PRE&gt;

&lt;P&gt;The response by paramagurukarthikeyan below shows how to do that in the custom end points created using &lt;CODE&gt;&amp;lt;your_app&amp;gt;/default/web.conf&lt;/CODE&gt; and &lt;CODE&gt;appserver/controllers/&amp;lt;your_endpoints&amp;gt;.py&lt;/CODE&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 21 May 2018 13:33:22 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-set-a-custom-HTTP-response-header-from-a/m-p/278544#M53325</guid>
      <dc:creator>arkadyz1</dc:creator>
      <dc:date>2018-05-21T13:33:22Z</dc:date>
    </item>
    <item>
      <title>Re: Is it possible to set a custom HTTP response header from a custom API endpoint?</title>
      <link>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-set-a-custom-HTTP-response-header-from-a/m-p/278545#M53326</link>
      <description>&lt;P&gt;¡Thank you arkadyz I have succesefully implmented it!&lt;BR /&gt;
The problem I had was related to CORS.&lt;/P&gt;</description>
      <pubDate>Thu, 31 May 2018 15:41:04 GMT</pubDate>
      <guid>https://community.splunk.com/t5/Getting-Data-In/Is-it-possible-to-set-a-custom-HTTP-response-header-from-a/m-p/278545#M53326</guid>
      <dc:creator>marcolesh</dc:creator>
      <dc:date>2018-05-31T15:41:04Z</dc:date>
    </item>
  </channel>
</rss>

