Run collections with file uploads using Newman


People have asked how to use the collection runner to run collections which have requests with file uploads. Right now, it’s not possible to upload files in the collection runner. However, you can use Newman, Postman’s command-line companion, as a workaround:

  1. Create a collection in Postman. Check out a sample collection here:

    This collection sends a single POST request, with two form parameters – one file param, and one text param.  The file that was used is The request runs successfully in the main Postman window:

Postman run successful
  1. Export the file as JSON (Collection > Export > V2), and save it to your filesystem.
  2. Open the JSON file for editing. In the request.body.formdata section, change the “src” property of the file param to the complete path of the file:
Edited collection file
  1. Run the collection JSON file using Newman:
Collection successfully run in Newman

If you are using Windows, be sure to change the backslashes (\) in the JSON file to double-backslashes so that the JSON remains valid, e.g. if your “value” is “C:\Documents\collection.json”, you’ll need to change it to “C:\\Documents\\collection.json”.

This is an updated post from Using Newman to run collections with file-post requests.


Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

8 thoughts on “Run collections with file uploads using Newman

  • Avatar

    Thanks for this article. However I have a question regarding integration as a git hook in a team project. As every user has a different configuration, file path won’t be the same from one machine to another. How can we make this more “dynamic” so everybody can use the same collection file ?

  • Avatar

    Hi ,

    Thanks for this article . I need one help , we are using raw data file in post command, We are sending file where we are exepecting some parameters value should get replaced with global variables values . We are unable to achieve this … can someone please help?

    • Avatar

      Hey, that shouldn’t happen, please post on the community forum if you’re still facing this issue:

  • Avatar

    Very useful, ty.

  • Avatar

    Can this “src” be parameterized to take input from JSON file.

    I have a requirement to import many files and the list of file names will be from input JSON data file. Does post man have this capability ?

  • Avatar

    This is now possible in the Postman Collection Runner. You just need to place your files in the default ~/Postman/files directory. This directory can also be configured in the settings.

  • Avatar

    I need to upload all files in one folder – tried to use “Folder\\.*.html” in ‘src’.
    but its not working… if anyone knows any workaround .. need to execute it with newman command.

  • Avatar

    We can follow the post in this blog but the easy way to that is just use newman option in your command –workign-dir “path to the files used in collection”
    Newman command looks like below:
    newman run “C:\Users\AKHAN9\Documents\Postman\postman_collection.json” –environment “C:\Users\AKHAN9\Documents\Postman\postman_environment.json” –workign-dir “path to the files used in collection”