I am trying to use a variable that has a null value in the body of a PUT. The null gets converted to “” after the post. Is there a way to have variable actually set the field null instead of an empty string?
thank you so much, I had the exact opposite issue… my variable was null and it was a required value so the POST was failing. but “null” with the double quotes works perfect.
Data should be a object that represents the current line in the CSV file, but I’m not sure you can change the element values in the object in a pre-request script. It’s a special variable. I don’t know if its read only or not.
I have just tested it. I can overwrite the data in the pre-request tab and console log it which shows the changes.
However, if I console log the data element in the tests tab, it hasn’t changed and if I add the variables to the body, they are taking the initial data from the CSV file, not the updated values.
So it looks like when you update the object in the pre-request script, the scope only applied to the pre-request script.
It looks like you will need to create a new environment\collection variable, and consume that instead. (Like the example provided by Danny).
Or put in a bug\feature request to get Postman to deal with the null values correctly (as they are valid JSON value type).