How to pass array with REST/FormData in a clean way?

arrays have to be passed like this: FormData: append() method - Web APIs | MDN

How to do it for a dynamic array with retool in a clean way?

@victoria thanks for opening a ticket for this.

My pleasure! I'll let you know as soon as we have any updates here :+1:

Hey again @andr3w! Just wanted to loop back here. Would you mind sharing a bit more about your use case so I can pass it along with the request?

@victoria sure. Sometimes we need to pass arrays to our API endpoint. The web standard dictates that we need to repeat the key and value to achieve that. Example: /api/v1/book?genre=FICTION&genre=THRILLER

At present, when using Form Data, we can only choose between text and file. It would be very useful if retool would parse arrays properly and set them as shown above. Given that this way of passing array is the W3C/TC39 approved standard - I ask that we escalate this to include it in the release as soon as possible.

my use case is that i have an API endpoint that requires to validate the data I get from retool and parse it properly, but all libraries expect the array data to be in the right format. At present, i pass the array as a string delimited by commas and then i split it at the server. This is a hacky workaround - i'd like to reduce hacky solutions. While fixing it for Form Data, please see if we can use a similar solution for search params in GET requests, given it's the same problem and requires a similar solution.