CSOM The request message is too big while uploading attachment

If you are using SharePoint client Object Model and you need to change max size of the message you need to pass to Client.svc, what you probably need is to increase the default value. This can occour for example if you are uploading files to a remote SharePoint using client object model.

The message you are receiving when executing query with client obejct model should be something similar to this: “The request message is too big. The server does not allow messages larger than 2097152 bytes.”

The property is MaxReceivedMessageSize of ClientRequestServiceSettings.The default value is 2MB (2097152 bytes).

Use this PowerShell script (from SharePoint Management Shell in Administrative mode with a Farm Administrative Account) to change this value, in the example below we are changing this limit to 5Mb, also is it possible to increase this limit to 2Gb.

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

If you want more information about this: https://msdn.microsoft.com/en-us/library/ff599489.aspx

Till the next time!!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s