This is the data that is passed in the postman.
I would to change the value of the scenario if the condition in the pre-request did not match.
My approach to do is:
if the condition didn’t match, then I’m calling this statement
pm.iterationData.toObject()[‘Metadata’][‘scenario’] = “negative”
How and where in Postman is that object currently set?
How is it being sent with with request? For example, how exactly are you setting the body for the request.
You appear to be using pm.iterationData which would indicate you are using a CSV or JSON import file. Is that correct?
Pretty sure the iterationData is read only, so you can’t update the elements directly, so you would have to initialize a variable and then update the scenario element within that variable, and then use that variable for the body.
Lastly, your response is an array with a single object in it. So you need to target that using the array index of .
body = pm.iterationData.toObject();
body.Metadata.scenario = "negative";
pm.request.body.raw = body;