File-uploads as part of a Collection run

For individual requests, you can simply set the body type to form-data ​, select a file, and send the request. Unfortunately, if you’re sending the same request as part of a Collection run, it’s a little more difficult than we’d like it to be at the moment. There’s an open feature request we’re working on to make it easier, but for now the recommended process is to use Newman, as follows:

  1. In Postman, set the body type for your request to form-data . Add a key, and select File ​ as the type:
    ​

    ​

  2. When you’re done working on your Collection, export it as a .JSON file so that it can be run with Newman

  3. Open the Collection you exported as a .JSON file, and search for the form-data key you created for your file upload. Look for the "src" property (it will be empty), and add the file path there:

{
"key":"your_key_here",
"type":"file",
"src": "" // <----- example: "src":"c:\\users\\files\\file.txt"
},

Please note that on Windows, you’ll need to make all backslashes in the file path doubled (as shown above), so that the JSON parses correctly.

  1. Install Newman (if you haven’t already)

  2. Run the Collection using Newman

Please let us know if you have any additional questions, get stuck, or if you have suggestions on improvements!

1 Like

False alarm: the reason it didn’t work is because I didn’t allow Postman to use files outside of my working directory
image

When I moved the files to the working directory, it worked. It was just a bit frustrating that there was no informative error message so it took me ages to figure out.