2
votes

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?

1
What's the script? Has anything been placed at the Collection or Folder level? It looks like something is trying to parse some HTML, that's the type of message you're likely to see.Danny Dainton
@DannyDainton there's no pre-request script. That section is empty. I even tried ctrl+a and delete just in case there were any whitespace characters in there I couldn't see.richflow
And that's at every level (Collection and Sub-Folder) not just at the Request level? There are 3 different places that a Pre-request Script can be called from. learning.getpostman.com/docs/postman/scripts/…Danny Dainton
@DannyDainton that was it! I wasn't aware you could have pre-request scripts at other levels. There was a pre-request script configured at the collection level. If you care to create an answer I'll mark it as accepted.richflow

1 Answers

3
votes

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