All Apps and Add-ons

How can I authenticate to the REST API, pass the query, and close the session (in one fell swoop)?

tony_alibelli
New Member

How set several request in one input ?

I must first authenticate to the REST API, then pass the query, and at end close the session

Regards

0 Karma

lguinn2
Legend

Yes, those are three separate steps, but I believe that you can combine them a bit. For example, this curl command should run authenticate and run a search, without creating a session.

curl -u admin:changeme -k https://localhost:8089/services/search/jobs -d search="search *"

This comes from the REST API tutorials: http://docs.splunk.com/Documentation/SplunkCloud/6.6.1/RESTTUT/RESTsearches
The difficulty is that this command returns a search job id, not the actual search results. You need to make a second call (shown in the tutorial) to actually retrieve the results.

If you use one the of SDKS (eg. Python or Java), you will see that they provide a "one shot" search as part of the SDK, which does do what you want. But I don't know how to do this with a single call to the REST API.

0 Karma
Get Updates on the Splunk Community!

Index This | What is broken 80% of the time by February?

December 2025 Edition   Hayyy Splunk Education Enthusiasts and the Eternally Curious!    We’re back with this ...

Unlock Faster Time-to-Value on Edge and Ingest Processor with New SPL2 Pipeline ...

Hello Splunk Community,   We're thrilled to share an exciting update that will help you manage your data more ...

Splunk MCP & Agentic AI: Machine Data Without Limits

Discover how the Splunk Model Context Protocol (MCP) Server can revolutionize the way your organization uses ...