Posting a list of files using a REST call with form-data

0
Hello!   For an integration we are doing we're sending a JSON request with an X amount of files using Form-Data. Right now this is not dynamic or generic, as we can only had key/values there per file. Meaning if we want to send multiple files, we need to add an activity per count of file with a different amount of key/value pairs, see image below: This works, but it's not pretty or maintainable.   A solution on our side is to convert the binary to a base64 and use an export mapping with a string, but the external party we work with does not accept this. Also zipping up the file is not accepted, as they only want one filetype per file (it's always the same 'content' but with a different extension), and zip already counts as 1 filetype, and they can't look inside it to validate during the REST call.   Another solution was implementing a Java action that handles everything generically, so we're i'd just make sure that i input a list of keys and files, but i'm not familiar with java actions and can't get that to work. Also, the maintainability of that with no java experts on the team is not something i'm comfortable with.   Is there any way the POST request remains the same structure, but a list of key/value can be sent instead a predetermined amount of key/value pairs like in the screenshot above?   Thanks!!!
asked
1 answers
0

You can’t send a dynamic list inside multipart/form-data keys, but you can:

  • Dynamically create keys like activity1.file, activity2.file, etc., in code (loop over files and set keys).

  • This keeps the same POST structure but works for any number of files.

  • If you can’t do this in your tool, a small Java or script action can build the request dynamically.

  • Ask the external party if they can accept repeated keys or a JSON metadata field to simplify things.

answered