Script Error when sending a request

Good morning, would anyone know how to solve this problem?

JSONError: Unexpected token 'E' at 1:1 EVENT_ RECEIVED ^

Thank you so much

Hey @lunar-module-sagani9 :wave:

Can you edit your title and question to explain the issue that you’re facing please. What you have now lacks context and information.

Please use this as a guide:

As, @danny-dainton mentioned, more context is needed to understand the issue and your use-case

But given the error posted in the title, if I have to hazard a guess, you have code in the β€œTest” tab that is trying to parse the API response as JSON, but the API did not return a valid JSON response. Thus, the failure to parse and the error.

  • Check if the API should return a JSON response
  • Check the test-script to make sure you if you should parse the response as JSON

This is nearly always because you have code in your tests tab (or pre-request script) that is trying to parse JSON data but is failing because the element you are trying to parse is not JSON.

JSON starts with either a { (to denote an object) or [ (to denote an array).

What the error is telling you is that the first character is an β€œE” so its an unexpected character\token. Have a look at the response, and I suspect it starts with β€œError” or similar.

This can happen if you are not getting 200 success status codes. A 401 authentication error does not return a JSON response, so if you try and parse that it will fail with the error in the title.

So you are looking at any pm.response.json() or JSON.parse elements in your code.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.