Hello, I want to send a multipart request where I have two xml files to be send in request body form data using http.post API. How do I do that?
I am trying with following code but I get
Request Failed error="unknown request body type func(goja.FunctionCall) goja.Value' exception.
import http from 'k6/http';
import {sleep, check} from 'k6';
import { FormData } from 'https://jslib.k6.io/formdata/0.0.2/index.js';
const job_config= open('../load-testing/request-files/job.conf-unmerge.xml')
const data= open('../load-testing/request-files/request-data.xml')
export const options = {
vus: 1,
duration: '1s',
}
export default function () {
const url = 'https://***';
const fd = new FormData();
fd.append('content', http.file(job_config));
fd.append('content', http.file(data));
const params = {
headers: {
'Content-Type': 'multipart/form-data; boundary=' + fd.boundary,
'Authorization': 'Basic ****',
}
}
const res = http.post(url, fd.body, params);
check(res, {
'is status 200': (r) => r.status === 200,
});
sleep(1);
}