I am having an issue with posting multipart form request to my API. I am getting this error The first argument must be of type string or an instance of Buffer, ArrayBuffer, or Array or an Array-like Object. Received an instance of Object
I have read multiple threads, but the solutions dont seem to work for my case.
- Using
{{ {...fileButton1.files[0], "data": fileButton1.value[0] } }}
link
- Excluding content-type in headers. link
If i had use {{ JSON.stringify({ ...fileInput1.files[0], data: fileInput1.value[0] }) }}
. The file is not included and ill get an error from my API, file is required
{
"request": {
"url": "https://xxxx/xxxx",
"method": "POST",
"body": {
"_overheadLength": 143,
"_valueLength": 428,
"_valuesToMeasure": [],
"writable": false,
"readable": true,
"dataSize": 0,
"maxDataSize": 2097152,
"pauseStreams": true,
"_released": false,
"_streams": [
"----------------------------538946954589778187697609\r\nContent-Disposition: form-data; name=\"file\"\r\nContent-Type: application/octet-stream\r\n\r\n",
{
"type": "Buffer",
"data": [......
]
},
null
],
"_currentStream": null,
"_insideLoop": false,
"_pendingNext": false,
"_boundary": "--------------------------538946954589778187697609"
},
"headers": {
"User-Agent": "Retool/2.0 (+https://docs.tryretool.com/docs/apis)",
"cookie": "admin_access_token=xxx",
"X-Retool-Forwarded-For": "122.11.135.151",
"content-type": "multipart/form-data; boundary=--------------------------538946954589778187697609"
}
},
"response": {
"data": {
"message": "\"file\" is required",
"code": 1
},
"headers": {
"content-type": [
"application/json; charset=utf-8"
],
"content-length": [
"43"
],
"connection": [
"keep-alive"
],
"access-control-allow-credentials": [
"true"
],
"date": [
"Thu, 15 Feb 2024 09:17:59 GMT"
],
"etag": [
"W/\"2b-8lYslSocUGZOq2Ukfjc4dLFAi84\""
],
"vary": [
"Origin"
],
"x-cache": [
"Error from cloudfront"
],
"via": [
"1.1 a9fb1933765b2e0a17ee7cee382c4058.cloudfront.net (CloudFront)"
],
"x-amz-cf-pop": [
"SIN2-P4"
],
"x-amz-cf-id": [
"3pQunpKnoPSunQWmwj9qlYPVMDVT3RdO5FOY-BJJUnucVVpUH7_SEw=="
]
},
"status": 400,
"statusText": "Bad Request"
}
}
oh i manage to reach my API with this
{{ { "name": fileInput1.files[0].name, ...fileInput1.value[0] } }}