Back to FAQs

How do I edit requests of type multipart/form-data?

The Loadster editor doesn’t yet have the ability to edit multipart/form-data bodies, and it’s not always possible to edit them as ordinary text because they often contain binary files.

If you want to edit multipart request bodies, for now, you’ll have to construct the body yourself and update it in your script with the Load… button.

Here’s a user-contributed example of building a multipart body using C#.

static void Main(string[] args) {
    using var form = new MultipartFormDataContent();

    // Add a file upload part
    var fileContent1 = new ByteArrayContent(File.ReadAllBytes("menu.jpg"));
    form.Add(fileContent1, "MenuFile", Path.GetFileName("menu.jpg"));

    // Add another file upload part
    var fileContent2 = new ByteArrayContent(File.ReadAllBytes("image2.jpg"));
    form.Add(fileContent2, "LogoFile", Path.GetFileName("image2.jpg"));

    // Add form fields here (key value pairs)
    form.Add(new StringContent("${token}"), "__RequestVerificationToken");
    form.Add(new StringContent("My name"), "Name");
   
    // Dump it to a binary file that can be loaded into Loadster
    using (var fileStream = File.OpenWrite("output.binary"))
    {
	fileStream.Position = 0;
	var copyTask = form.CopyToAsync(fileStream);
	copyTask.Wait();
    }
}

Similar utilities most likely exist in your language of choice.

We plan to add better multipart editing support to Loadster in the future. If you find yourself doing this often, please shoot us an email at help@loadster.app with your vote for prioritizing a proper editor for multipart bodies!