Uploading file error


I am sending files to upload, I get return code 400, but I can’t understand why.

Steps to reproduce

Version 5.10.0.
Send request via cUrl
curl -X POST
-H ‘Authorization: Bearer 1tg1wkq3a3nsjy8cqxinggbanw’
-H ‘Content-Type: multipart/form-data’
-H ‘Postman-Token: 27fc8d02-a2d3-4f6b-8b4e-d18b014e982f’
-H ‘cache-control: no-cache’

Expected behavior

Sending the file path (which has already been saved in host directory) and the channel through cURL, should receive a positive API return, something like the pattern:
“file_infos”: [
“id”: “string”,
“user_id”: “string”,
“post_id”: “string”,
“create_at”: 0,
“update_at”: 0,
“delete_at”: 0,
“name”: “string”,
“extension”: “string”,
“size”: 0,
“mime_type”: “string”,
“width”: 0,
“height”: 0,
“has_preview_image”: true
“client_ids”: [

Observed behavior

Receiving return with error
{“id”:“api.file.upload_file.read_request.app_error”,“message”:“Não foi possível enviar o(s) arquivo(s). Erro ao ler ou decodificar a requisição.”,“detailed_error”:"",“request_id”:“7jawnwn71pnkdkhh1xyne6xmio”,“status_code”:400}

I’m using portuguese language, but the error message is something like “The file (s) could not be sent. Error reading or decoding request.”

Hi @paulus,

Is this happening with certain or all file sizes / dimensions?

Also, wondering if some of these previous threads might help:


I was trying to send by PHP cURL the file path, but I was supposed to use the PHP function ‘curl_file_create’. Now is working properly.

Thanks so much for attention.

1 Like

This error can appear when we’re trying to specify formBoundary. Just do not specify it, or put an empty string. It will be set from browser autocratically.

const fileFormData = new FormData();
fileFormData.append('channel_id', channelId);
fileFormData.append('client_ids', data.file.uid);
fileFormData.append('files', data.file.originFileObj, data.file.name);
await client4.uploadFile(