SharePoint Error: The server does not allow messages larger than 2097152 bytes

后端 未结 4 2056
渐次进展
渐次进展 2021-02-19 09:08

I have web service that point to sharepoint 2013 Office 365. I use the client object model. I am trying to update the xml file which stores 4 attachments in it. When I do thi

4条回答
  •  不知归路
    2021-02-19 09:29

    SharePoint has its own limits for CSOM. Unfortunately, these limits cannot be configured in Central Administration and also cannot be set using CSOM for obvious reasons.

    When googling for the issue, mostly a solution is given by setting the ClientRequestServiceSettings.MaxReceivedMessageSize property to the desired size.

    Call the following PowerShell script from 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 setting to also limit the amount of data which the server shall process from a CSOM request (Why anyone would configure this one differently is beyond me...). After reading a very, very long SharePoint Log file and crawling through some disassembled SharePoint server code, I found that this parameter can be set via the property ClientRequestServiceSettings.MaxParseMessageSize.

    We are now using 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 that saves some people a headache!

提交回复
热议问题