Using Newman to run collections with file-post requests

A lot of people have been asking 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
Postman run successful
  1. Export the file as a JSON, and save it to your filesystem.

  2. Open the JSON file for editing. In line 22, change the "value" property of the file param to the complete path of the file:

Edited collection file
Edited collection file
  1. Run the collection file in Newman:
Collection successfully run in 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 tutorial has been updated:

  • How can I do export to JSON in 2nd step?

    • abhijitkane

      In the main Postman window, in the collection sidebar on the left hand side, hover our cursor over the collection name. You should see a 'Share collection' icon.

  • Jacob Rieger

    I'm trying to run a collection with a file upload post, however it always returns 404. It works in the chrome app fine. I'm thinking it has to do with not finding the filename?

    • Jacob Rieger

      Just did some testing, looks like it's finding the file, but when I isolated it into a single request in a collection, I get an unexpected end of input error

      • Guest

        Nevermind, it was all on my end. Love the tool! Thanks

  • Danconia

    I'm trying to run newman with a file upload for different set of files. I'm using "-d" and specifying a json file with the additional filepaths. However, it iterates with only the one file mentioned in the collection.

  • Spyros Katopodis

    I downloaded Newman in order to be able to download files using the collection runner. However, after trying to run a collection I always receive the following error:

    Iteration 1 of 1
    throw er; // Unhandled stream error in pipe.
    Error: EISDIR, read
    at Error (native)

  • Jón Brynjar Másson

    Can I integrate newman with my build server which is Bamboo instead of using Jenkins?

  • Diệu Thanh

    I create a collection in Postman and export the file as a JSON. I'm trying to run Newman but the file does not work (It works with Postman). It has this error "ReferenceError in test-script".
    How to overcome this error?

  • Cang Dinh

    Read the last post.

    1. You dont need to set the property enabled
    2. instead of "value" you use "src"

  • Mahek

    How do I give custom name to collection runner report file using newman?
    I tried ,
    newman -c mycollection.json -o outputfile.json
    But the output file name is newman-run-report-2016-10-19-10-26-34-619-0.
    Is it possible to give custom name?

  • Alexander Salas Bastidas
  • Josh

    I think I'm following everything perfectly, but I keep getting the error:

    *unable to load form file for upload: "undefined" . *

    The records I'm trying to create still get created successfully, they just don't have the attachment included with them.

    Anyone know what that error message means?

    • Daniela

      Hey Josh,
      I was having the same issue and finally this worked:
      "key": "invoice",
      "type": "file",
      "enabled": true,
      "src": "C:\\Documents\\invoice.jpg"
      So I needed to have 'src' rather than 'value', and needed to add the extension of the file.