File upload with newman

I want to run my test on server side( in the process of CI) so want to use newman.
Also my test has lots of file upload. but seems newman process doesn’t support file upload by itself.

Is there any good way to test with command line on linux and many file uploading?

Thanks!

  • kousuke

One way to make this work is to replace the values of all src properties for files in request bodies with an appropriate file name, or with environment variables that point to file paths on the CI agent. For instance,
src: '/path/to/file/to/be/uploaded'

or,
src: '{{variable_containing_file_path}}'

1 Like

Hi,

I am facing issue in uploading file when I run the collection with newman via CI/CD.However,It works for me when I run locally via newman.It fails only when I run it via CI/CD.

Steps I have followed:

  1. I’ve given the src with the file name that I want to upload.For the sake of simplicity I’ve kept collection file and the file that I upload below in same folder

“body”: {
“mode”: “formdata”,
“formdata”: [
{
“key”: “”,
“type”: “file”,
“src”: “Image.jpeg”
}
]
},

  1. When this request runs in Jenkins the exact path of the file that I upload would be in ‘C:/Jenkins/Workspace/ApiAutomation/Myproject/collections’. So I have given this as working directory in the newman command

–working-dir C:/Jenkins/Workspace/ApiAutomation/Myproject/collections

The Issue I am facing is still the error log says ‘no such file’ and the API call returns 500 error.

I want to know

1)What would be the default working directory when we run it via newman command

2)For the issue I face, what are all the things I have to check from my end to resolve the ‘no such file’ error.

Any help on this would be much appreciated.Thanks in advance.

Did you have a solution for this case? The same thing happened to me with azure pipeline