Uploading files > 2MB to Sharepoint using BizTalk 2013 CSOM

The other day I was working on an application that would be uploading files to SharePoint 2013 using BizTalk 2013.

With BizTalk 2013, Microsoft has introduced CSOM (Client Side Object Model) and as a result of which there no need to install the SharePoint Service that was required till BizTalk 2010.

Everything seems to be working fine till uploading a file of size 1.8 MB and BizTalk failed to upload the file with below exception.

https://biztalkbox.files.wordpress.com/2014/06/image001.png

So the error is clearly the server exception and SharePoint is not allowing files of size > 2097152 byes or approx 2MB.

There is one interesting stuff to check here.. The file size being uploaded is 1.8 MB and allowed size is 2 MB so why is it failing ??

After digging on to SharePoint logs you could see the content of the file and the content is a Base64 string. So this clarifies the reason as Base64 string is greater than the original data so a 1.8MB data could well grow > 2MB after Base64 conversion..

But still a 2MB limitation is too much and it should not be like this.

There is a setting in SharePoint where you can increase this size limit. It can be done using a power shell script.

Add-PSSnapin Microsoft.Sharepoint.Powershell

$service = [Microsoft.Sharepoint.Administration.SPWebService]::ContentService

$service.ClientRequestServiceSettings.**MaxParseMessageSize **= 2147483647

$service.ClientRequestServiceSettings.**MaxReceivedMessageSize **= 2147483647

$service.Update()

Using the above script the size can be increased to 2 GB and after running the script everything went fine and files of size 200, 250 MB were getting successfully uploaded.

Note : Its the MaxParseMessageSize that actually does the trick :)

 

See Also

Another important place to find a huge amount of BizTalk related articles is the TechNet Wiki itself. The best entry point is BizTalk Server Resources on the TechNet Wiki.