How to fix it: JSONError: Unexpected token 'F' at 1:1 Forbidden ^

For anyone else reading this topic, let me explain the error and what is causing it.

JSONError: Unexpected token ‘F’ at 1:1 Forbidden ^

This is caused by having a JSON parse command somewhere in your script.

pm.response.json() or JSON.parse()

These functions are expecting a JSON format, so whatever they are targeting should either start with a [ for an array, or { for an object (an array is a special type of object, but that is a a conversation for another day).

In the above case, its not returning JSON, but a forbidden error. Therefore the first character which is an ‘F’ in unexpected. You’ll also see errors showing ‘H’ because a HTML response has been returned instead of the expected JSON.

1 Like