Limitation of uploading big file to SharePoint 2013 with CSOM

In category SharePoint | January 8, 2015

We have recently rolled out an Outlook plugin that integrates with SharePoint. The plugin allows end users to upload selectable email to SharePoint 2013 libraries. Client-side object model (CSOM) is used for the plugin development. We realized that if the email’s size was more than 2MB, it was unable to be uploaded to SharePoint 2013 libraries. The following message was thrown out:

“The request message is too big. The server does not allow messages larger than 2097152 bytes.”

We just figured out that SharePoint 2013 has limit when using CSOM. The default value to make a request through CSOM is 2MB if you have never paid attention to CSOM setting. There is a property called MaxReceivedMessageSize in SPWebService object that is adjustable.

To allow big files to be uploaded through CSOM, use the following PowerShell snippet code:

$a = [Microsoft.SharePoint.Administration.SPWebService]::ContentService
$a.ClientRequestServiceSettings.MaxReceivedMessageSize = 209715200
$a.Update()

Note: make sure SharePoint Timer service is stopped before you execute the above PowerShell

You could programmatically set the MaxReceivedMessageSize property using C# snippet code below

public static void IncreaseMaxReceivedMessageSize()
{
SPWebService contentService = SPWebService.ContentService;
contentService.ClientRequestServiceSettings.MaxReceivedMessageSize = 10485760;  // 10MB
contentService.Update();
}

If you use built-in SharePoint API, you might need to read this article: Quick tip to overcome limitation of uploading using SharePoint web service

For more information about increasing the Maximum Message Size, read this article http://msdn.microsoft.com/en-us/library/office/ff599489(v=office.14).aspx

[Update – 27/01/2015] Jason has a good tip for uploading large files via CSOM with SaveBinaryDirect method and MemoryStream.

Share

5 thoughts on “Limitation of uploading big file to SharePoint 2013 with CSOM

  1. Le Van Son says:

    Need to set max parse message size as well:

    $a.ClientRequestServiceSettings.MaxParseMessageSize = 209715200

  2. rohit says:

    is this supported in sharepoint online? we have designer list workflow against sharepoint online site which is pretty big. when we try to save the workflow, we get above mentioned error. any way to change this property in SPO?

    1. Abhay says:

      Hi Rohit
      I am encountering the same issue – have you been able to resolve your issue? any tips

Leave a Reply