Hello There ,
I am trying to Load test file upload functionality for my Application via APIs.
I noticed that the Content-type which is being sent as a payload is not showing the correct boundary values which is resulting in failure.
Here is my K6 Code and the response
import http from "k6/http";
import { check } from 'k6';
import { FormData } from 'https://jslib.k6.io/formdata/0.0.2/index.js';
const file = open('./test.xlsx','b');
export default function () {
const formData = new FormData();
formData.append("projectId", "ae5034a5-723d-4743-b5c8-0b03bbba1a43");
formData.append("files",file,'test.xlsx');
let res11 = http.post(
'https://web-url/v1/Excel/UploadExcelFile', formData.body(), {
headers: {
Authorization: 'Mytoken',
'Content-Type': `multipart/form-data; boundary=${formData.boundary}`,
//'Content-Type': `application/octet-stream`,
//'Content-Type': formData.contentType,
},
}
);
check(res11, { "status is 200": (r) => r.status === 200 });
const jsonData11 = JSON.parse(res11.body);
console.log("UploadExcelFile Status: "+res11.status+" "+res11.error);
console.log(jsonData11)
sleep(1);
}
This is what i see in my logs
Whereas, same request sent from Postman for this particular API, the content-type in the console looks like this
Content-Type: multipart/form-data; boundary=--------------------------207119253063992349634509
Can anyone please help me resolving this issue.
Thanks in advance.