Other Usage

Splunk Rest API response in JSON format

Eshwar
Engager

Hi experts,

We are in the process of sending the alerts from Splunk to another application via REST API but response of the REST API is displaying in XML format as our other application would have expect  JSON format however we tried using Postman application as well but the response is same in XML so can any one suggest  JSON response REST API to get the alert details?

Thank you in advance.

Regards,

Eshwar

0 Karma

scelikok
SplunkTrust
SplunkTrust

Hi @Eshwar,

Please try below;

curl -k -u admin:password  "https://localhost:8089/services/alerts/fired_alerts?output_mode=json&count=0"
If this reply helps you an upvote and "Accept as Solution" is appreciated.

Eshwar
Engager

Hi @scelikok ,

That's working great.

Thank you for saving my time.

Regards,

Eshwar

 

0 Karma

scelikok
SplunkTrust
SplunkTrust

Hi @Eshwar,

You can add "output_mode=json" parameter to get json output. Please see below;

curl -k -u admin:password https://localhost:8089/services/search/jobs/export -d search="search sourcetype=splunkd earliest=-1h" -d output_mode=json

 

If this reply helps you an upvote and "Accept as Solution" is appreciated.
0 Karma

Eshwar
Engager

Hi @scelikok ,

I tried with output_mode=json but not able to get JSON response as my REST end point is for fired alerts as below.

https://localhost:8089/services/alerts/fired_alerts

0 Karma
Get Updates on the Splunk Community!

Index This | I’m short for "configuration file.” What am I?

May 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with a Special ...

New Articles from Academic Learning Partners, Help Expand Lantern’s Use Case Library, ...

Splunk Lantern is a Splunk customer success center that provides advice from Splunk experts on valuable data ...

Your Guide to SPL2 at .conf24!

So, you’re headed to .conf24? You’re in for a good time. Las Vegas weather is just *chef’s kiss* beautiful in ...