Postman ‘There was an error in evaluating the Pre-request Script’ but pre-request script is empty

postmanpostman-pre-request-script

I have a shared collection on Postman. When I run the request in the shared collection it fails with the following error:

There was an error in evaluating the Pre-request Script: Error: Unexpected token '<' at 1:1 ^

I have tried this with several requests, the simplest request being a GET request to 'http://localhost:8000/v1/resource' with no parameters, authorization, headers, body or pre-request script and the above error still occurs.

Checking postman's console I see the following error:

JSONError: Unexpected token '<' at 1:1 ^

Which matches the one above.

When I duplicate the request and place it outside of the shared collection it works fine.

Not sure what I'm missing?

Best Answer

As it's a shared entity, I suspect that a team member/the Collection creator may have added a script to a different part of the Collection.

There are 3 different levels that a Pre-request Script can be called from in Postman. The Collection level, the Sub-Folder level and the from within a single Request.

More information can be found here:

https://learning.getpostman.com/docs/postman/scripts/pre-request-scripts/#adding-a-pre-request-script-to-a-collection-or-folder

Related Topic