Why Does an Error Occur When I Upload a Large File in SharePoint?

Symptoms

When I upload a large file in SharePoint, usually larger than 2 MB, this error message shows:

The request message is too large. The server does not allow messages that are larger than 2097152 bytes.

Cause

The default upload limit of SharePoint CSOM is 2 MB.

Prerequisites

Resolution

  1. Use a PowerShell script to increase the upload limit in SharePoint.

    Format:

    $ws = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
      $ws.ClientRequestServiceSettings.MaxReceivedMessageSize = {file size in bytes}
      $ws.ClientRequestServiceSettings.MaxParseMessageSize = {file size in bytes}
      $ws.Update()

    Example:

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

More Information

https://reshmeeauckloo.wordpress.com/2016/02/23/sharepoint-2013-how-to-increase-the-file-upload-limit-for-csom-from-2-mb-to-20-mb/

https://msdn.microsoft.com/en-us/library/office/ff599489(v=office.14)