When you are usingMicrosoft. Sharepoint. Client. filecollection. AddMethod orMicrosoft. Sharepoint. Client. file. savebinaryWhen creating or modifying a file in the SharePoint library, you may encounter the error "the remote server returned an error: (400) Bad request. To solve this problem, you need to modify the default maximum Message Size of SharePoint.
Open the SharePoint 2010 management shell and execute the following command:
$ Ws = [microsoft. Sharepoint. Administration. spwebservice]: contentservice
$ Ws. clientrequestservicesettings. maxcompute edmessagesize = your_value
$ Ws. Update ()
We recommend that you set the size of maxcompute edmessagesize to int32.maxvalue-1, that is, 2147483646.
In general, you may need to force restart your IIS service. You can use the following command:
Iisreset/noforce
Or, you can also useMicrosoft. Sharepoint. Client. file. savebinarydirectMethod to upload files. This method does not limit the file size. For more information about how to use it, see my other article.Article"Notes about Sharepoint client object application ".