Passing request body multiform-data file source as variable in postman.

Issue:

In postman if we check the UI, we notice that there is no way to define file path as variable.

This looks like a limitation when we need to run file from different systems

Solution:

The solution is to hack the collection.json file. Open the json and edit the formdata src and replace it with a variable, let say fire_path so : {{fire_path}}

Now in Postman:

in pre request you can below code to set the path

pm.environment.set("file_path","C:/Users/guest/Desktop/1.png")

You can also save it as environment variable directly or pass through cmd using — env-var when using newman.

Note:

set access file from outside working directory as true (settings from top right corner)

--

--

Praveen David Mathew
Praveen David Mathew

Written by Praveen David Mathew

An open source advocator/WebdriverIO Projectcommiter/Postman Supernova/Postman-html-extra contributor/Stack overflow sqa moderator/Speaker

No responses yet