Getting Data In

Why do I get "error parsing XSL Stylesheet" when I look at REST API URLs directly on splunkWeb?

sideview
SplunkTrust
SplunkTrust

When using the rest API, the app I'm working on uses REST API Urls like

/splunkd/__raw/servicesNS/USERNAME/APPNAME/saved/searches

but whenever I paste these URL's into my browser to sanity check something, it doesn't work.
Specifically I get an error in Firefox saying "Error loading stylesheet: Parsing an XSLT stylesheet failed.", and in Chrome the page loads blank. At least with Chrome I can view-results and see the XML source.

Does anyone know what causes this and how I can fix it?

Tags (2)
0 Karma

sideview
SplunkTrust
SplunkTrust

What is happening, is that the /splunkd segment is giving you access to the somewhat more "real" rest API on the splunk management port (typically 8089),

and with the default output_mode being "xml", the results come back with this a directive on it to use a particular XSL stylesheet:

<?xml-stylesheet type="text/xml" href="/static/atom.xsl"?>

Now if you were actually making this request on the management port, there is an XSL file at /static/atom.xsl. However on the Splunkweb port it's a different http server and there is no such file there.

When you hit these URL's using something like curl or an XMLHttpRequest object in Javascript, they don't care about the missing stylesheet. But for whatever reason browsers treat this as a fatal error.

So bottom line, this isn't really a serious problem - it's just a mild and occasional annoyance for developers.

SOLUTION: You can quite easily fix this by copying the atom.xsl file from $SPLUNK_HOME/etc/system/atom.xsl over to $SPLUNK_HOME/share/splunk/search_mrsparkle/exposed/atom.xsl

and restart splunkweb. The problem will go away.

OR, you can also not use the default xml outputmode. 😃 Tack on ?output_mode=json to get json instead (and thus you wont get any xsl stylesheet directive at all.

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.

Can’t make it to .conf25? Join us online!

Get Updates on the Splunk Community!

Take Action Automatically on Splunk Alerts with Red Hat Ansible Automation Platform

 Are you ready to revolutionize your IT operations? As digital transformation accelerates, the demand for ...

Calling All Security Pros: Ready to Race Through Boston?

Hey Splunkers, .conf25 is heading to Boston and we’re kicking things off with something bold, competitive, and ...

Beyond Detection: How Splunk and Cisco Integrated Security Platforms Transform ...

Financial services organizations face an impossible equation: maintain 99.9% uptime for mission-critical ...