2

I am using rocket chat rest API, every thing works good, but when i upload file to rocket chat rest api, it shows error 413 Request Entity Too Large, but when i upload file from website it uploaded any size of fie.

After checking all scenario, I concluded that file size less than and equal to 1 mb is uploaded successfully, and greater than 1 MB shows this error 413 Request Entity Too Large.

I upload file from post man using this url https://rocket.chat.url/api/v1/rooms.upload/RoomId

Headers:

Content-Type:application/x-www-form-urlencoded

X-Auth-Token:User-Token

X-User-Id:User-Id

Form-Data:

file - selected file

Html result Error

<html>
<head><title>413 Request Entity Too Large</title></head>
<body bgcolor="white">
<center><h1>413 Request Entity Too Large</h1></center>
<hr><center>nginx/1.10.3 (Ubuntu)</center>
</body>
</html>

when File successfully insert it shows following.

{
   "success": true
}
Community
  • 1
  • 1
Faraz Ahmed
  • 1,125
  • 13
  • 26

1 Answers1

3

After checking many scenarios and search many urls i get solution from this.

I have used rocket chat docker and I append one line to nginx config file.

Solution:

  1. login to ubuntu server
  2. write sudo nano /etc/nginx/nginx.conf and hit enter
  3. Add or update client_max_body_size in
http {

    client_max_body_size 8M; #used your exceeded limit instead of 8M

    #other lines...

}
  1. Restart nginx by command service nginx restart or systemctl restart nginx
  2. Uploading larger file again, and it is successful.
Ivica Pesovski
  • 516
  • 2
  • 20
Faraz Ahmed
  • 1,125
  • 13
  • 26