The code is given as: let incomingPayload = JSON.parse(globals.previousRequest).data; pm.collectionVariables.set("newPayload", incomingPayload.message)
Body:
{{newPayload}}
Error:
âThere was an error in evaluating the Pre-request Script:JSONError: Unexpected token u in JSON at position 0â
I canât for the life of me understand this error or spot how I misunderstood the instructions.
I tested further by trying console.log(pm.globals.get(âpreviousRequestâ)); at the beginning of the Pre Script and it is undefined. I donât seem to understand what is expected from this step at all.
That script in the echo request relates to the functionality of the Webhook you created when itâs Triggered. It wouldnât work in isolation or as a single request.
When you trigger the Webhook, you should see the output of this in the monitor that what created for it.
Iâm not really sure what the problem is here, the echo request is not intended to be run as a single request.
With the pre-request code, thatâs very specific to the webhook functionality, itâs going to error.
Triggering the webhook, if thatâs been created correctly, will run the Collection in the Monitor and the results of that can be seen on the monitors console.
Iâm not sure Iâve ever found the expected console logs - 'Echoing my payload: ', pm.response.json().data
Going back over this again, it appears somehow I was running the previous dayâs (28 UI testing) collection in my monitor. I deleted the monitor, verified I had Day 29âs Collection Id as my variable and triggered a new webhook.
It is running properly now. I get that the first echo call wasnât supposed to run on its own, I guess it was just where I started looking when my monitor wasnât running properly.