Since there is no documented way of adding saved searches / alerts via the web framework, I thought I try to connect to the REST API with jquery from inside the dashboard like:
var getSessionKey = $.ajax({
type: "POST",
url: "http://172.x.x.x:8089/services/auth/login",
data: "username=xxx&password=xxx",
crossDomain: true
}),
I edited the server.conf to allow CORS (crossOriginSharingPolicy = *), but this is also not working. It seems like Splunk is adding the header "x-splunk-form-key" automatically to every request. Since the only allowed header for CORS regarding the REST API is "authorization" this request fails, because of a CORS violation.
I tried to remove the header for my request with things like...
beforeSend: function(xhr){
xhr.setRequestHeader('x-splunk-form-key', ' ');
},
or
beforeSend: function(xhr){
xhr.setRequestHeader('x-splunk-form-key', null);
},
, but unfortunately this changes nothing in the request. I also did not find any way to allow additional headers for REST API requests.
Any ideas from anyone?
Thanks!
... View more