rest api batch GET request throwing 500 internal server error

dileepppdominic
Tera Contributor

I was trying to fetch data through servicenow batch request but somehow it is throwing 500 status code error. Please find the payload and the error message. Please advise me. 

 

payload = {
    "batch_request_id":"1",
    "rest_requests":[
            {
                "id":"1",
                "headers":[
                    {"name":"Content-Type","value":"application/json"},
                    {"name":"Accept","value":"application/json"},
                    {'name': 'Authorization', 'value': f"Bearer {access_token}"}
                ],
                "url":"/api/now/table/incident",
                "method":"GET"
            }
        ]
    }
 
Error Message: 
 
{"error":{"message":"Cannot invoke com.glide.sys.Transaction.setAttribute(String, String) because this.fTransaction\\" is null","detail":"Cannot invoke \\"com.glide.sys.Transaction.setAttribute(String, String)\\" because \\"this.fTransaction\\" is null Check logs for error trace or enable glide.rest.debug property to verify REST request processing"},"status":"failure"}
processing
3 REPLIES 3

Omkar Kumbhar
Mega Sage
Mega Sage

Hello @dileepppdominic ,

Change the headers to below example and try

{
  "batch_request_id": "1",
  "rest_requests": [
    {
      "id": "1",
      "headers": {
        "Content-Type": "application/json",
        "Accept": "application/json",
       "Authorization": "Bearer {access_token}
      },
      "url": "/api/now/table/incident",
      "method": "GET"
    }
  ]
}
 
Later you can also check by Removing the Authorization header from the inner request and pass it only in the outer request

If I was able to help you with your case, please click the Thumb Icon and mark as Correct.

thanks for the answer but still having same error and without Authorization header it is throwing Authorization error.

https://testdd9999.service-now.com/api/now/v1/batch --------------------
Migrating Jira issue in Batch No 1, from 1 to 2 Completed
{'error': {'message': 'User Not Authenticated', 'detail': 'Required to provide Auth information'}, 'status': 'failure'}
Migration completed please verify the migration report excel file

Hello @dileepppdominic ,

 

IT looks like authentication issue. Please try to check the token if it is expired. 

Next check if the user you are using to authenticate has access rights.

Also, check the migration report for issue if any mentioned. Also share the screenshot if possible.

 

Regards,

Omkar

If I was able to help you with your case, please click the Thumb Icon and mark as Correct.