Fixed: The request message is too big. The server does not allow messages larger than 2097152 bytes while uploading attachment using CSOM in SharePoint 2013


Got below error while uploading document to SharePoint folder.

Following PowerShell script can be used to increase the limit.

$ws = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
$ws.ClientRequestServiceSettings.MaxReceivedMessageSize = 5242880
$ws.ClientRequestServiceSettings.MaxParseMessageSize  = 5242880
$ws.Update()

https://msdn.microsoft.com/en-us/library/office/ff599489%28v=office.14%29.aspx

Hope it helps !