Sending CSV with an API Request

I'm trying to upload a CSV file as a multipart/form-data request in Retool, where the API expects a csv file. I've set up the request with the following configuration:

  • Headers include Content-Type: multipart/form-data.
  • Body uses file: {{conversion.data}} (with conversion as a JavaScript query returning a Blob).
  • Another parameter, attempts, is passed as text.

However, the API isn't recognizing the file correctly. Any guidance on formatting the Blob or structuring the request would be appreciated!

This is the error that I'm facing:
The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received undefined.

image

Hello @MoathK!

Apologies for this issue, are you able to share the console log of csv and the console log of the blob?

I am guessing you already looked at both of those to confirm that the data was in the correct format but just wanted to check.

From our docs on uploading a csv to a database, it should be possible to not have to convert the data to a blob, but to pass table2.selectedRow.user_id in to the body of your post request.

Have you tried that already? I am very confused why the error is telling you that the server received undefined :thinking:

I was thinking of seeing if you can convert the array of table2.selectedRow.user_id using some JS as described here, but it seems that you are essentially already doing that. Given that like 11 and 12 from your screen shot just adds in a CSV file header and commas to the on value(user_id) that you are grabbing from the table :face_with_monocle:

Which makes me think, if none of those options work for changing the JS script, that the issue might be with how the query/resource is set up. Just to confirm, this is a REST API resource, correct?

Can you try making this POST request to postman and seeing if you are getting CSV in the body or if that is also coming in as undefined?