File upload through discord webhook

Hello there,
I can’t figure out how to correctly send a string as .txt file through a discord webhook. I always receive error 400 bad request. Does anyone know how to properly do this?

Some context: Discord Developer Portal

function Util.SendFileToWebHook(url, data, filename)
    PerformHttpRequest(url, function(err, text, headers) print(err) end, "POST", string.format(data), {
        ["Content-Disposition"] = 'form-data; name="file"; filename="' .. filename .. '"',
        ["Content-Type"] = "multipart/form-data"
    })
end
end

Have you figured it out?

What I achieved with node.js, is to send an embedded image.
I suppose this should also work with other file types.

const axios = require("axios");
const FormData = require("form-data");
const fs = require("fs");

// The 'data' parameter contains the usual webhook json stuff, like embeds etc.
const sendFileWithPayload = async (url, path, data) => {
    const form = new FormData();
    form.append("file0", fs.readFileSync(path), path);
    form.append("payload_json", JSON.stringify(data));
    await axios.post(url, form);
    fs.unlinkSync(path);
}