I am trying to upload file (excel {xlsx}) to an API using k6.
I am using the K6 script
k6>process.js
this script call an api (Asp.net core API (5.0)).
The file(s) are uploaded but file uploaded file(s) are not correct.
Navigate to main parent directory and change directory to k6
in k6 directory please run process.js script using k6 run ./process.js
uploaded files are found in API>FileUpload>Recources>Images
Using POSTMAN to upload files using the same endpoint works as expected. Please find postman export under directory name PostMan.
The Post action is used to send content of excel as binary data.
You wrapping the body in http.file means that it will make the body to be a multipart-form which is what you then dump to the file. You should just fileContent as the body.
edit: I have made you a PR with both the “fix” and a Dockerfile I needed to make so I can test it.
Hello, i’m a new to k6 and i have some issue.
I’m trying to send a POST request to upload xlsx files to an API. It’s doesn’t work with Postman as well.
When i try to display the fileContent from fileContent = open(“./files.xlsx”, “b”), its seems empty. And when i try to display the results body from res = http.post(url, fileContent, params) i have this error, “Cannot deserialize the current JSON object”.
I’m using the same script as below (process.js)