Splunk Search

Pass JSON or XML as parameters to custom Python script via Splunk REST API

highsplunker
Contributor

Hey guys,
How to
Pass JSON or XML as parameters to custom Python script via Splunk REST API ?

Example:
I use REST API like this
curl -ku MyUser:MyPwd https://MyServer:8089/services/search/jobs/export?output_mode=json -d search=' | MyScript param1 param2 '

What if I want these parameters
param1 ="JonSnow"
param1 ="[{\"name\":\"Ned\",\"house\":\"Stark\"}]

Version 6.5.2 or 7+ of Splunk.

Tags (1)
0 Karma
1 Solution

highsplunker
Contributor

Hey guys,

Solved long time ago. This is standart: passing smth like JSON thru REST API is just passing a string parameter for a custom Python script (when calling via REST API a search like " | myScript arg1=\"aaa\" arg2=\"bbb\" "

View solution in original post

0 Karma

highsplunker
Contributor

Hey guys,

Solved long time ago. This is standart: passing smth like JSON thru REST API is just passing a string parameter for a custom Python script (when calling via REST API a search like " | myScript arg1=\"aaa\" arg2=\"bbb\" "

0 Karma

arjunpkishore5
Motivator

Could you provide more clarity on this? Are you trying to implement a custom REST endpoint?

0 Karma

highsplunker
Contributor

Hi, I've updated the question. Please take a look.

0 Karma

arjunpkishore5
Motivator

Still doesn't make sense. Is you script hosted as a custom REST Endpoint ?

0 Karma

highsplunker
Contributor

It's just a custom script on my server that runs several Splunk searches. I want to pass not only alphanumeric parameters, but a json package to my searches to be used in alerting rules.

0 Karma
Get Updates on the Splunk Community!

Technical Workshop Series: Splunk Data Management and SPL2 | Register here!

Hey, Splunk Community! Ready to take your data management skills to the next level? Join us for a 3-part ...

Spotting Financial Fraud in the Haystack: A Guide to Behavioral Analytics with Splunk

In today's digital financial ecosystem, security teams face an unprecedented challenge. The sheer volume of ...

Solve Problems Faster with New, Smarter AI and Integrations in Splunk Observability

Solve Problems Faster with New, Smarter AI and Integrations in Splunk Observability As businesses scale ...