New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
handle file download request from Newman #413
Comments
@swapnilpatne You mean saving the request to a file? |
I mean when a response of a request is file e.g. pdf or zip or xml file etc |
Hmm, Newman will expose the responseBody as the |
Is there a way by which from "tests" tab in Postman I can read the filename returned in response header and then write a javascript code to get that response written in file? And then can run those requests from newman? |
@swapnilpatne Well, writing to a file will require using one of the write methods from fs, which is currently not included within the Postman Sandbox. |
Is this being targeted for the next release? As a newman user I feel that this is a very important feature and blocks of lot of API operations that are centered around files or storage. |
Do we have any update regarding this feature? |
@kiranwilson This isn't in the works presently, but we'll update this thread when any progress is made. |
@kunagpal Thanks for the response |
@swapnilpatne @kiranwilson @shikhartanwar As a workaround, you can have the following snippet in a file, say var i = 0,
fs = require('fs'),
newman = require('newman'); // ensure that you have run "npm i newman" in the same directory as this file
newman.run({
// run options go here
}, function (err, summary) {
// handle collection run err, process the run summary here
}).on('request', function (err, execution) { // This is triggered when a response has been recieved
if (err) { return console.error(err); }
fs.writeFile(`response${i++}.txt`, execution.response.stream, function (error) {
if (error) { console.error(error); }
});
}); You can then run the script above with |
I run as |
@chitzinwin You'll have to specify the collection as an option in the first argument to |
Perfect! It's working now. @kunagpal Thank for prompt response! |
Closing issue. Also on another note, someone can create a newman reporter that saves all responses to file :-p |
So the send and download feature is not available in newman? Postman always relies on third party code to handle its upload data? You cant actually fully automate sending files using newman? You always have to add some third party code to get files completely separately? Every time you want to share a postman collection with other developers you also have to send them dependencies of the postman tests completely separately? Newman can't manage files it needs for its tests on its own? Why isn't this being worked on? |
How to handle file download request from Newman? Can someone please answer?
The text was updated successfully, but these errors were encountered: