Is there a way to log/store all the raw api requests and responses when we run postman collection in newman?
There is an open PR: https://github.com/postmanlabs/newman/pull/218
The PR is merged, so I'm closing this issue. @vishbin, you can use the -O <filename> option to enable verbose logging to a file, which will contain the request/response data.
Sorry, I may be blind, but the log file (I tried both -t and -o) does not have request and response data. Are there any other settings I have to care about?
@ok11 The correct option is -O (note that the "o" is capital).
You can also use --outputFileVerbose, which is an alias to -O.
Edit: Also, the -O is not a zero. It's a capital "o".
Thanks! The issue was that I typed small o, not capital. It works now.
@czardoz , @ok11 Hello guys, can you please help me with this... because i am getting the below error when using -O or --outputFileVerbose
I am using newman v3.5.2 on windows10 machine
command issued : newman run E:\postman_collection.json -e C:\environment.json -d C:\data.json -O E:\new.txt
console output: newman run: error: Unrecognized arguments: -O E:\new.txt.
@Guru426 Check the readme for supported options: https://github.com/postmanlabs/newman#readme
Specifically, the reporter options :)
@czardoz what part of that link gives information regarding "Unrecognized arguments: -O" ?
@crowcoder The -O option comes from Newman v2, and has been discontinued as of Newman v3. More details here.
@kunagpal, to summarize what I found from those links:
To get request/response logging, you must use the JSON reporter.
(Or make your own reporters or templates)
Is that correct?
_edit_ yeah: https://github.com/postmanlabs/newman/pull/218#issuecomment-303328770
Is there no way of easily creating a file with each request/response pair in it?
I found I could do this with the html reporter, and a custom ".hbs" file
This really should be easier, though - I have had to copy a file and modify it. If you release any changes to that file, I will not see them unless I update my copy of the file.
Couldn't the request/response body be included in the .hbs file? Or you could ship an alternate .hbs file with them included?
Thanks
@kunagpal which alternative can be used for newman's higher versions?
i'm on 4.3.1 and I want to view both request and response body in the running logs (on the same screen) without needing to self log the details in all the tests
@kunagpal which alternative can be used for newman's higher versions?
i'm on 4.3.1 and I want to view both request and response body in the running logs (on the same screen) without needing to self log the details in all the tests
Same here
which alternative can be used for newman's higher versions?
It's 2021 and I still cannot find any. I wish they could at least include a default custom logger for that purpose.
Postman's Runner has "Save responses" flag. It would be very helpful to have it on newman too.
A quick Google yielded this - https://www.npmjs.com/package/newman-reporter-cli-response
We encourage community to extend newman using reporters.
@shamasis yes.
But it would be ideal if Newman is usable out-of-the-box. "what response did we get that caused this failure?", is a completely standard thing to ask
Completely agree. It's a use case and valid. There's no good way to print request and response bodies while running a collection of tests.
With it being a separate reporter, its most likely that the use case will be better handled with focus and dedication in a reporter than have it diluted within the primary use case of running tests.
And installing a reporter is seamless. Guess what, if come across any such reporter, I will link here.
@shamasis I've looked through 100+ different reporters on npmjs a few months ago and could not find one that does the job. There are a lot more and a lot of them are severely outdated. It makes the search very difficult.
Thanks for the link above, it seems like it's what we need. But as with any other npm packages - it can be abandoned and stop working at some point.
Newman can be used as a docker image - https://hub.docker.com/r/postman/newman/
In fact it looks like it's a very popular image. Adding the reporter to an image creates more hustle of either creating a custom image that a company has to maintain or add tons of scripts to preset it upon startup.
We use newman in our CI/CD via k8s using the image above. It makes the setup even more complex. And the more complex setup you have the more resources you have to spend to maintain it.
A simple flag (that is already available in PM's Runner) would save a lot of hustle and human/hours.
Ok. I hear you.
There's an ongoing work for Newman to be curl replacement for extended debugging of a single request. Let us learn from doing that - especially how the output looks like and what code flow will allow us to re-use the code here.
Once that is settled, we will roll it in form of a built-in reporter.
cc @codenirvana
Greetings!
Our team is observing newman fail due to mysterious "Parse Error" with responseBody undefined. This implies that newman failed to even make the connection to the server under test, possibly due to an intermittent networking issue.
When I have problems like this, typically my go-to tool is curl -v -v -v which logs everything we need to understand the root cause. However, because newman has nothing like this (???) I'm presently waiting for our tests to fail and then trying to use tcpdump to capture the (transient, extremely short-lived) networking or DNS glitch.
Adding some kind of verbosity - maybe enabled via an environment variable - would be tremendously helpful as my team has already collectively burnt something like 10 hours trying to figure out why newman fails sporadically for completely mysterious reasons.
@noahlz Sorry to hear that... Your issue seems similar to #2725. Can you also add any more ideas/thoughts that you have regarding this there? It'll help us to come up with a solution that fits your use-case as well. 馃檪
Most helpful comment
@shamasis I've looked through 100+ different reporters on npmjs a few months ago and could not find one that does the job. There are a lot more and a lot of them are severely outdated. It makes the search very difficult.
Thanks for the link above, it seems like it's what we need. But as with any other npm packages - it can be abandoned and stop working at some point.
Newman can be used as a docker image - https://hub.docker.com/r/postman/newman/
In fact it looks like it's a very popular image. Adding the reporter to an image creates more hustle of either creating a custom image that a company has to maintain or add tons of scripts to preset it upon startup.
We use newman in our CI/CD via k8s using the image above. It makes the setup even more complex. And the more complex setup you have the more resources you have to spend to maintain it.
A simple flag (that is already available in PM's Runner) would save a lot of hustle and human/hours.