Newman run with relative file paths in form-data for file upload

Hi !

I am running postman tests in travis-ci with newman. Every time I modify my tests from the postman client, I export the JSON and the tests are ran from travis when pushed.

The problem is I want to test my file upload route but when I export the Collection, a Absolute path is exported for the file in form data !

Even though I have the working directory set. How can I overcome those issues without to have to edit the JSON manually every time ?

Ideally, Postman would export the files as a relative path that I can then do something with on travis, like creating the required folders etc…

Thanks !

You can use either the Public link or the Postman API to run the collection. It will save you from exporting the file each time a change is made.

How / Where are you setting the working directory? In the app or with the newman flag?

--working-dir <path>
Set the path of the working directory to use while reading files with relative paths. Default to current directory.

Thanks for the reply !

I like to export the collection so it can be source controlled with git, so we avoid having problems when multiple PRs are running in CI and they try to run a request on a route that isn’t on this PR. Unless you have another solution ? :smiley:

For the working directory, I set it in Postman’s desktop client. The problem is still that the collection looks for an absolute path (in my case /Users/seluj78/Postman/files/logo.png) on my macbook which obviously isn’t an existing directory in travis and alike CI runners. How can I work around that and pass files that are inside the repository so that the collections will work when exported and when on the desktop client ?

Have you tried setting a specific location using the Newman flag? Setting this in the app isn’t the same thing as setting these for the newman run.

--working-dir <path>
Set the path of the working directory to use while reading files with relative paths. Default to current directory.

I’ll try it now. Thing is, in the postman collection, exported as JSON, the path isn’t relative !

Check it out here: https://github.com/Seluj78/PyMatcha/blob/41fafd7feb0f6361c4531a99cc821463bf65b5f4/PyMatcha.postman_collection.json#L3797

I would recommend replacing that path with a Postman variable.

This allows you to have control over it both from Postman and when doing CI/CD.