Batch API doesn't work

sppatel
Tera Contributor

I am following the API documentation for using the batch API - but I get the same error even for the most simplest of payloads.

 

curl -X "POST" "https://myinstance.service-now.com/api/now/batch" \
     -H 'Content-Type: text/plain; charset=utf-8' \
     -u 'foo:bar' \
     -d $'{
  "batch_request_id": "1",
  "rest_requests": [
    {
      "id": "1",
      "method": "GET",
      "url": "/api/now/table/incident?sysparm_limit=1"
    }
  ]
}'

 

{"error":{"message":"Requested URI does not represent any resource","detail":null},"status":"failure"}


Any guidance on what the issue could be?  I've tweaked the payload to several different URLs/methods but results in the same error.

 

1 REPLY 1

risanchez
Giga Expert

This is happening because the documentation is wrong and not specifying the API version is NOT an option. You must use api/now/v1/batch. v2 doesn't exist either, which they also seem to imply in the docs. I spent a good hour or so understanding what was going on in my case. Very frustrating that ServiceNow pays so little attention to their code/documentation.  BTW - The BATCH API shows a lot of potential but it's also riddled with undocumented behavior (a.k.a. bugs). Who would have thought! 🙄