Script Error using Pre-Requests

Hi, there! I’m newbie in Postman and I’m having an error i’m unable to solve. I’ve looked already for an answer but I haven’t found a topic that could help me.

I’m trying to launch a Pre-request Script in JSON but I always see the same error: “SyntaxError: Unexpected token ‘<’”

I’m trying to download a package from an application and it’s seems not worked.

This is the code I’m trying tu run:

Hey @anaskoualal :wave:

Welcome to the Postman Community! :postman:

That appears to look more like a request body (I might be wrong here) than a script.

If you add that JSON to the Body > Raw section and choose the JSON option from the dropdown, does that unblock you?

1 Like

It seems to work (the result above), I close the request, thank you very much for the answer @danny-dainton !

Just a quick question before closing: do you know where it goes when it’s ok? i.e. how do I visualize the result? do I need to create an additional script?

Thank you in advance for the reply !

1 Like

Glad to see you have it working! :tada:

The response from that request, would be in the Pretty/Raw/Preview tabs on the same line as Visualize. I don’t know what your response looks like to know if it could be visualised.

You would need to add a seperate script (manually or using Postbot) to your Tests section, in order to display a visualized response.

More information on this can be found on our learning center:

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