K6 Script sending a request to the backend APIs but the parameter is empty



i have a k6 script that reads two images and send them to a .net core API, the script is:

import http from "k6/http";

const path = "path/image1";
const path2 = "path/image2";

const image1Byte = open(path, "b");
const image2Byte = open(path2, "b");
const image1Name = "image1.jpeg";
const image2Name = "image2.jpeg";

export default function () {
  try {
  } catch (error) {
    return null;

async function sendFiles() {
  const url = "path/to/server";
  const image1 = http.file(image1Byte , image1Name );
  const image2 = http.file(image2Byte , image2Name );
  const files = [];
  let response = http.post(url,{files});
  return response;

the API that receives the request is:

public virtual async Task<ActionResult<Dictionary<string, long>>> PostFiles([FromForm] List<IFormFile> files)

in the above case the request is caught at the api, but files at the API is always has count of 0, although if i send only one image to the API such as:

const files = image1

it reaches the API correct and i can read its data of the image1, what I’m doing wrong here? keep in mind that in both cases the request reaches the API but in list case the parameter files is empty

Can you try like in this example? Data Uploads

I mean

const fd = new FormData();
fd.append('files', image1);
fd.append('files', image2);

let response = http.post(url,fd.body(), {
    headers: { 'Content-Type': 'multipart/form-data; boundary=' + fd.boundary },