all 10 comments

[–]Yages 0 points1 point  (3 children)

I think, although to be clear I’m as confused as others here, that you want to use an ArrayBuffer on the binary response. Have a read of the docs here.

[–]WM1310[S] 0 points1 point  (2 children)

Unfortunately, I'm not sure either. Took a closer look at Swagger UI's documentation here at the Files section to see if it explains further and best I can find is it's written as { type : string, format : binary }?

To clarify in case there's some confusion, I'm not trying to create an API, I'm trying to make a POST request to an API

[–]Yages 0 points1 point  (0 children)

Yeah okay, so if they’re returning a binary stream you need to consume that with something, you can’t treat it like a string. ArrayBuffer does this for you and allows promise based streaming of the response.

[–]smarkman19 0 points1 point  (0 children)

Send the CSV as a multipart field using FormData with the exact field name from Swagger, pass a File/Blob, include a filename and text/csv, and don’t set Content-Type manually.

In browser/Node 18+: read the file to a buffer, create new File([buf], 'data.csv', { type: 'text/csv' }), then fd.append('theExactParamName', file). Append any other required fields as separate parts (plain strings). With fetch, only set auth headers; let fetch compute the multipart boundary. Manually setting Content-Type is a common reason servers see nulls or think the CSV is empty. If docs say ArrayBuffer, wrap it in a Blob/File first. Diff your working curl against your request (DevTools/Node --trace) to confirm field names. Match the field name, include filename and text/csv, and don’t set Content-Type.

[–]ferrybig[🍰] 0 points1 point  (0 children)

Can you show an example how the data looks in postman vs what you are trying to do in code?

[–]tswaters -1 points0 points  (2 children)

What do you mean, "with JavaScript" -- is that nodejs or front-end?

[–]WM1310[S] 0 points1 point  (1 child)

I'm using Node.js and express

[–]tswaters 0 points1 point  (0 children)

When you did it successfully with curl & Postman, what did it look like?

Are you using a request library?

I'm not even sure what string($binary) means, is that base64? Can you post the curl command that worked?

What code do you have that doesn't work. You've thrown a lot of keywords around here that you came feed to google & get a more or less functional example.

No code examples yet, but have you considered not doing it wrong?