Change filename in form-data in pre-request script

I have a test case which posts form-data, including several files. I would like to change the name of one of the files before request is sent. I am not looking to change the name/path of the local file used to compose the request; I am looking to change the name of the file specified in the request posted to the server. My objective is to add some bad characters (ex. control characters) into the filename so I can confirm that the server correctly handles this situation.

Using the console.log function I have found the request object which includes the request.data property. The request.data property includes the other form variables, but not the form files. I have found posts from others mentioning that the files are not included into the request until after the pre-request script runs.

If that is true, can anyone suggest another way or approach to achieve my objective?

I am using v7.20.1 of Postman in a Windows environment.

Thank you!

2 Likes