How to specify content type for individual formdata elements

Is it possible to use something like Blob in K6, in order to have form data elements with different content types? i.e one is a file (easy enough), another is json. Each would have their own respective content types.

Something like:

const fd = new FormData();
   fd.append('bookInfo', new Blob([JSON.stringify({
        name: "Book",
        quantity: "12"
    })], {
        type: "application/json"
    }));
  fd.append('testFile', http.file(someFile, 'somefil.txt', 'application/octet-stream'));

Hi @jclarknet, welcome to the forum and sorry for the slow reploy :bowing_man:

It seems to not have been documented but you can just append an object with keys:

  • data - which will be the data you want
  • filename - you can skip that if you don’t want filename set.
  • content_type - with the content type you want, if not provided it will be application/octet-stream

You can see it done here