My code
import http from "k6/http";
import { check } from "k6";
import { FormData } from "https://jslib.k6.io/formdata/0.0.1/index.js";
const img1 = open("/C:/Users/M1059024/Downloads/test_photo.png", "b");
export default function () {
const requestPayload = new FormData();
//requestPayload.append('data', http.file(img1, '2.png', 'image/png'));
requestPayload.append('images', http.file(img1, 'image1.png'));
requestPayload.append("env", "local");
requestPayload.append("brandcode", "CBR");
requestPayload.append("agentmasterid", "Q00200000FDFAr8QCHj9H2tck8J5eXHfCZHRJC7C");
requestPayload.append("guid", "488EF450-AAB2-46F3-A81A-73758A59ED5B");
requestPayload.append("cbagentid", "");
requestPayload.append("loadflag", "False");
console.log("test");
console.log(requestPayload.body());
const requestHeader = {
apiKey: "2QucUpePK1nnirL6LhjBc4QAhxwXSutm",
Authorization: "Bearer <redacted>",
"Content-Type": "multipart/form-data; boundary=" + requestPayload.boundary,
};
const res = http.post(
'https://lsn2ob7pb5.execute-api.us-west-2.amazonaws.com/dev-apm-photo/photo',
requestPayload.body(),
{
headers: requestHeader,
}
);
}
I am expecting the form-data content type to be multipart but the data is coming as octalstram. Can any please help me fix this issue?