I am having hard time lately trying to use an HTTP Request node to send a multipart/form-data payload . To make it understandable we could say the call I am trying to do is this kind :
But the number of attachements may vary from 0 to N. And for each of them I need to append the form a new Key ‘fileX’ with the binary file as the value and app to my Json table behind key = ‘payload’ a new line “ { “type”: “ATTACHMENT”, “contentType”: “file”, “file_key”: “fileX” }”
If you want to upload multiple files to your endpoint where the number of files differs every time, the best solution would be to split up your files and send them as separate HTTP requests as suggested here:
This way, the number of files shouldn’t matter.
Also, I’m not sure what you mean here:
but you should be able to reference the item’s index number with file_{{ $itemIndex }}:
the thing is that i must put the N number of file in the same POST to have them handle by the system as one entity . which is what i need. => It won’t work if i do multiple calls .
So that’s why i need to append the files in one form. (as i do in my code node)
when i say : “I can’t make a variable of the number of files”
it means i can do using an HTTP node to build a form from input files, but can’t have the number of file in the input unknown . This need to be a fixed number of file .
so i could switch case if 1 file , if 2 files , if 3 files etc … but then will have a much number of similar node to maintain .
My idea was to use the Code node to build the form . Then i wanted to pass the built form to an http node to handle “creds, http calls, retry , error …” that it does pretty well.
But i don’t understand how i can pass that form from the code node to the http node.