Tests OK in Postman but KO in newman?

Hello to the Postman community :slightly_smiling_face:,

Here I run into a concern about using newman on a test campaign I created in postman. Indeed in some of my test scenarios I test the upload of a pdf file. The POST requests that handle upload all return status 201 in Postman as I see fit.

In newman, however, some of these requests return a 415, as if the format was not supported by the API.

I tried to run a newman run mycollection.json --verbose to try to see the contents of the headers, but it did not give anything. Impossible to visualize the headers.

Here are the headers and more specifically the Content-Type on the Postman side:

My environment and my collection are up to date. My OS is ubuntu 20.04.
I don’t understand why the API returns the correct status (201) in Postman and not in newman

I am at your disposal for more information


I’d guess from looking at the output (no such file), that you need to express the full file path for the PDF.

eg; /tmp/Postman/filename.pdf

1 Like

Hello @w4dd325,

Thank you so much, you put me on the path.
Indeed the paths of my files were incorrect in my json collection file.

I don’t understand how this is possible. I was careful to update the export of my collection. I had to change the path by hand in the collection file (22,000 lines…). I didn’t find any other way. But it works now.

1 Like

Could you not throw your collection.json file into Notepad++ and do a find and replace?

Or even throw it back in Postman and add the filename as a variable so you only have to change it in 1 location?

Just a thought. Glad it’s working for you now!! :upside_down_face:

Thanks for your answer @w4dd325 ,

Indeed I used ctrl+f to find each “src”, then I pasted the right path. Otherwise I’m interested in the second option you describe. But how do I create a variable with file names? For now I will search for the files in my working directory, then add them to the body of the request.

I have not done it myself but there is a discussion about it here.

Hope it helps.

This is how I have done this exact same thing.

  1. You can run a bash script to do find and replace after exporting your collection. This will hopefully add the correct location of your needed files.

There is another option as well though… You can use the working Directory. The working directory is also used by Newman, so any test needing a file upload should work the same if your file is located there.

Do you by any chance have an example of the bash script?

1 Like

It has been a bit since I have ran this but if you leave the source blank then you can do this. The script/exported collection and file need to be in the same file as it is setup here. This will also replace ALL instances where there is not a file specified in the collection used.

sed -i 's/"src": ""/"src": "filename.pdf"/g' mycollection.json
1 Like


Thanks for the replies ! Indeed I tried the method used by @vdespa and it’s work well.

But actually I don’t see how to create a variable on the path especially since the body of the request offers a location using the file manager and not a written path.

For @whersh, I’ve already set up the working directory like this:
Capture d’écran du 2022-02-01 19-41-47

I’m going to try your method with the bash script. Do you have the source of your bash script or a tutorial where this is explained? The next challenge will be to share this collection with the rest of my team.

Thanks to both of you

Sorry I do not have a source or a tutorial as I wrote this myself. I am sure looking a bit of sed documentation will help with the explanation. Example tutorial

Shareing the collection can either be done a few different ways but a few are described here in the sharing section of Postman documentation

Thanks for your help @Whersh !