When running a script calling the Search Job API I am sporadically receiving the following error message with some of the requests. I have verified the job ID is valid per the initial request, so why do we receive this message?
"status" : 404,
"id" : "X7X3X-EDY9M-FORQQ",
"code" : "searchjob.jobid.invalid",
"message" : "Job ID is invalid."
When using the Search Job API you will need to ensure you store the cookie from the original search job request and then pass this cookie back with any follow-up requests to get the results of that job.
The cookie is needed to tell the Sumo Logic load balancers which service node is managing the generated search. If you do not pass back the cookies with the request its possible for your request to hit a node that is unaware of the search and a 404 error will be returned.
Note: The following examples will need to be performed against the API endpoint for your account deployment. For more information on determining the endpoint needed for your account please see the following documentation.
Examples using cURL:
Start the job:
curl -b cookies.txt -c cookies.txt -H 'Content-type: application/json' -H 'Accept: application/json' -X POST -T createSearchJob.json --user ACCESSID:ACCESSKEY https://api.sumologic.com/api/v1/search/jobs
Request the status:
curl -v --trace-ascii - -b cookies.txt -c cookies.txt -H 'Accept: application/json' --user ACCESSID:ACCESSKEY https://api.sumologic.com/api/v1/search/jobs/12345678999999
Request message results:
curl -v --trace-ascii - -b cookies.txt -c cookies.txt -H 'Accept: application/json' --user ACCESSID:ACCESSKEY 'https://api.sumologic.com/api/v1/search/jobs/12345678999999/messages?offset=0&limit=10