web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :

Resolved: The request message is too big. The server does not allow messages larger than 2097152 bytes in Sharepoint

Community member Profile Picture Community member

Hello everyone,

Today I was trying to upload a document on Sharepoint programmatically. However due to file size limitation for uploading a file on Sharepoint, I got the issue “The request message is too big. The server does not allow messages larger than 2097152 bytes.”

I googled the resolution for the issue, but almost every resolution involved running the Powershell script.

However I didn’t want to run the powershell script and yet wanted to resolve my issue.

So after some R&D and googling, I found the resolution as below:

I was using below code for setting the content of the message

FileCreationInformation.Content=Convert.FromBase64String(fileData);
//fileData being the document body of my attachment.

Instead of using the Content method of FileCreationInformation, I used ContentStream as below:

FileCreationInformation.Content=new MemoryStream(Convert.FromBase64String(fileData));

This resolved the issue.

Points to consider when chosing the method:

File upload option Considerations When should you use this? Supported platforms
Content property on theFileCreationInformation class. Maximum file size that can be uploaded is 2 MB. Time-out occurs after 30 minutes. Use to upload files that are less than 2 MB only. SharePoint Server 2013, SharePoint Online
SaveBinaryDirect method on the File class. No file size limits. Time-out occurs after 30 minutes. Only use this method if you’re using a user-only authentication policy. User-only authentication policy is not available in an app for SharePoint, but can be used in native device apps, Windows PowerShell, and Windows console applications. SharePoint Server 2013, SharePoint Online
ContentStream property on theFileCreationInformation class. No file size limits. Time-out occurs after 30 minutes. Recommended for:
  • SharePoint Server 2013.
  • SharePoint Online when the file is smaller than 10 MB.
SharePoint Server 2013, SharePoint Online
Upload a single file as a set of chunks using the StartUpload,ContinueUpload, andFinishUpload methods on theFile class. No file size limits. Time-out occurs after 30 minutes. Each chunk of the file must upload within 30 minutes of completion of the previous chunk to avoid the time-out. Recommended for SharePoint Online when the file is larger than 10 MB. SharePoint Online


This was originally posted here.

Comments

*This post is locked for comments