Splunk Search

Create Search using REST/JSON

Tops_NI
Engager

I can successfully create a search job with the help of the docs using a Curl command:

curl -u "userName" -k https://host:port/services/search/jobs -d search="encodedSearchQuery"

I get back the SID as expected:

<response>
<sid>1234567890.123456</sid>
</response>

 

When I try to translate this search to a REST Call with JSON body I cannot get it to work. For example if I use postman:

POST

https://host:port/services/search/jobs/

Request Body (JSON)

{
"search": "encodedSearchQuery"
}

 

I get a 200 but no Search job created or SID returned.

 

Any tips to get this working?

Thanks

Labels (1)
0 Karma
1 Solution

Tops_NI
Engager

Seems I had to post the data as Key Value pairs using Content Type application/x-www-form-urlencoded rather than a JSON request body.

View solution in original post

0 Karma

Tops_NI
Engager

Seems I had to post the data as Key Value pairs using Content Type application/x-www-form-urlencoded rather than a JSON request body.

0 Karma
Get Updates on the Splunk Community!

Index This | I am a number, but when you add ‘G’ to me, I go away. What number am I?

March 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...

What’s New in Splunk App for PCI Compliance 5.3.1?

The Splunk App for PCI Compliance allows customers to extend the power of their existing Splunk solution with ...

Extending Observability Content to Splunk Cloud

Register to join us !   In this Extending Observability Content to Splunk Cloud Tech Talk, you'll see how to ...