What would be the correct HTTP get request call syntax to fetch saved search data from Splunk if we're accessing it through an access token?
My curl command is working but http.get is not.
curl command:
#os.system('curl -H "Authorization: Bearer <token>"
<baseurl>:8089/services/search/jobs/export --data search="savedsearch abc_backup_status" -d output_mode=csv')
request call ::::
BASE_URL = '<baseurl>:8089/services/search/jobs/export'
data = {"search":"savedsearch abc_backup_status"}
headers = {'Authorization': "Bearer <token>"}
auth_response = requests.get(BASE_URL, headers=headers, data = data, verify=False)
this is giving 400 errors.
The curl options
-dOR--dataimply aPOSTmethod by default.From: https://man7.org/linux/man-pages/man1/curl.1.html
It is interesting that Splunk Docs claim that
search/jobs/exporttakes a GET, but you're creating a job to immediately export, which feels like a POST type of operation.Also I notice that your search starts with the savedsearch command, if that's a regularly scheduled savedsearch, you may want to GET
saved/searches/{name}/historyto get the last execution SID, followed either by the results or events endpoint of that already executed job, instead of a new search.... but that's a use case question