local function post_to_n8n(endpoint, json) local http = require("http") local client = http.client() local request = http.request("POST", endpoint, json) request:header_set("Content-Type", "application/json") local result, err = client:do_request(request) if err then log_print("post_to_n8n error: " .. err) error(err) end end -- files_table should have the form: -- { -- fieldname = "file", -- path = "./test/data/test.txt" -- } local function post_file_to_n8n(endpoint, files_table, form_fields_table) local http = require("http") local client = http.client() local file_request = http.file_request(endpoint, files_table) -- file_request:header_set("Content-Type", "application/json") local result, err = client:do_request(file_request) if err then log_print("post_file_to_n8n error: " .. err) error(err) end if result then log_print("post_file_to_n8n result Code: " .. result.code .. " Body: " .. result.body) end end -- This ends up being a POST form-encoded request will = "to_win" is a form field value post_file_to_n8n( "https://endpoint.sample", { { fieldname = "file1", path = "/Users/rodo/trabajo/rodley/botbunny/bot-bunny-go/Icon.png" }, { fieldname = "file2", path = "/Users/rodo/trabajo/rodley/botbunny/bot-bunny-go/cmd/cli/bf467f02-fa3a-4b67-981a-eaa39c56332f.pdf", filename = "custom-b.pdf" } }, { will = "to_win" } )