SharePoint error: server does not allow sending messages larger than 2097152 bytes

I have a web service that points to sharepoint 2013 Office 365. I am using the client object model. I am trying to update an xml file that stores 4 attachments in it. When I do this, when I have large binary data in an xml file, I get the following error:

Message

The request message is too large. The server does not allow sending messages over 2097152 bytes.

I understand that I will probably have to separate the attachments from the XML file, but my info form currently stores them there. Is there a way to increase the length of the request or maybe save or something else. I really just change one node and it will not work unless I update xml. Thank you The code is below.

My code is:

ListItem docReq = GetDocRequestLight(docRequestID, businessID); string fPath = (string)docReq["FileRef"]; using (FileInformation fInfo = Microsoft.SharePoint.Client.File.OpenBinaryDirect(ctx, fPath)) { XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(fInfo.Stream); XmlNamespaceManager xmlNameSpaceMgr = new XmlNamespaceManager(xmlDoc.NameTable); xmlNameSpaceMgr.AddNamespace("my", DocReqXmlNameSpace); // Get Parent Node XmlNode node = xmlDoc.SelectSingleNode(GetXPathFromItemKey(velmaKey), xmlNameSpaceMgr); DateTime outDate; bool outBool; if (DateTime.TryParse(newValue, out outDate)) node.InnerText = outDate.ToString("yyyy-MM-dd"); if (Boolean.TryParse(newValue, out outBool)) node.InnerText = newValue; // Update Statuses XmlNode statusIDNode = xmlDoc.SelectSingleNode(DocReqStatusIDFieldXPath, xmlNameSpaceMgr); statusIDNode.InnerText = updatedStatus.ID.ToString(); XmlNode statusNode = xmlDoc.SelectSingleNode(DocReqStatusFieldXPath, xmlNameSpaceMgr); statusNode.InnerText = updatedStatus.Name.ToString(); // Save File docReq.File.SaveBinary(new FileSaveBinaryInformation() { Content = Encoding.UTF8.GetBytes(xmlDoc.OuterXml), }); ctx.ExecuteQuery(); 
+7
sharepoint sharepoint-2013 csom
source share
2 answers

SharePoint has its own limitations for CSOM. Unfortunately, these restrictions cannot be configured in central administration and also cannot be set using CSOM for obvious reasons.

When searching for a problem, the solution is mainly set by setting the ClientRequestServiceSettings.MaxReceivedMessageSize property to the required size.

Call the following PowerShell script from the SharePoint Management Shell:

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

This will set the limit to 200 MB.

However, in SharePoint 2013, Microsoft apparently added another configuration parameter to also limit the amount of data that the server should process from the CSOM request (why would someone configure it differently, outside of me ..). After reading a very long SharePoint log file and scanning some disassembled code for the SharePoint server, I found that this parameter can be set using the ClientRequestServiceSettings.MaxParseMessageSize property.

Now we use the following script with SharePoint 2013 and it works great:

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

Hope some people have a headache!

+16
source share

I just ran into this problem in SharePoint 2013 and after looking at the docs it says:

Content property in the FileCreationInformation class. The maximum file size that can be downloaded is 2 MB. Timeout occurs after 30 minutes. Use only files smaller than 2 MB to download.

However, if you set the ContentStream property, you will not reach the same document size limit. The documentation states:

ContentStream in class FileCreationInformation . No file size. Timeout occurs after 30 minutes. Recommended for: - SharePoint Server 2013. - SharePoint Online when the file is less than 10 MB.

There are some other parameters in the documentation, but hopefully this will help other people who are faced with this same problem.

+2
source share

All Articles