Using Newman to run collections with file-post requests Abhijit Kane November 15, 2014 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: Create a collection in Postman. This collection sends a single POST request, with two form parameters – one file param, and one text param. The file that was used is https://gist.github.com/abhijitkane/4aba1c3deeb4ed61a623 The request runs successfully in the main Postman window: Postman run successful Export the file as a JSON, and save it to your filesystem. Open the JSON file for editing. In line 22, change the “value” property of the file param to the complete path of the file: Run the collection file 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: https://blog.postman.com/2017/09/21/run-collections-with-file-uploads-using-newman/ In this post Tags: Newman Abhijit Kane Abhijit Kane is co-founder and head of product at Postman. View all posts by Abhijit Kane → What do you think about this topic? Tell us in a comment below. Comment Cancel replyYour email address will not be published. Required fields are marked *Your name Your email Write a public comment Δ This site uses Akismet to reduce spam. Learn how your comment data is processed. 14 thoughts on “Using Newman to run collections with file-post requests” Kirill November 16, 2014 How can I do export to JSON in 2nd step? abhijitkane November 21, 2014 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 December 12, 2014 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 December 12, 2014 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 December 12, 2014 Nevermind, it was all on my end. Love the tool! Thanks Danconia April 7, 2015 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 July 15, 2015 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 stream.js:94 throw er; // Unhandled stream error in pipe. ^ Error: EISDIR, read at Error (native) spyros@spyros-SZ77:~/npm-global/lib/node_modules/newman/bin$ Jón Brynjar Másson January 21, 2016 Can I integrate newman with my build server which is Bamboo instead of using Jenkins? Diệu Thanh August 18, 2016 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? Thanks. Cang Dinh September 1, 2016 https://github.com/postmanlabs/newman/issues/525 Read the last post. Tl:dr: 1. You dont need to set the property enabled 2. instead of “value” you use “src” Mahek October 19, 2016 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? Josh November 24, 2016 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? MSo December 3, 2016 I was getting the same warning message (* not an error *) when I ran newman command line scripts exported from postman. I looked into the collection JSON file and for all GET requests, postman inserted unrequired/unneeded “body” element in the “request” block for each GET request that had form-data information (used to upload a file). This was probably leftover from previous testing in postman I was doing at the time. When I removed the entire “body” element from the GET request block, the warning message disappeared. I would inspect the JSON file for any unused “body” element that has “form-data” info in your request blocks and remove them if they were exported w/o really serving any purpose. Daniela February 7, 2017 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. You might also like Working with the Postman CLI Gbadebo Bello The Postman CLI is the official command-line tool for Postman. It lets you run collections, publish workspaces, lint API specs, trigger monitors,… Read more → Your API Tests Belong in the Pipeline – Here’s How to Get Them There Danny Dainton Your Postman Tests Are Only Valuable If They Run Automatically You probably already have the tests. Requests with assertions, test scripts that… Read more → Reusable Requests: Enhancing Modularity and Efficiency Danny Dainton Imagine treating a request in Postman as a reusable component, not something you copy and paste across collections, but something you define… Read more →