I use the following method to upload a document to the sharepoint document library. However, after executing the request, you will receive the following error: Message = "The remote server responded to the error: (400)" Bad request ".
files fail more than 1 mb, so I tested it through the sharepoint user interface and the same file that was downloaded successfully.
any thoughts on what the problem is? Is it possible to transfer a stream over more than 1 large fragment of a file? This file is only 3 MB in size.
private ListItem UploadDocumentToSharePoint(RequestedDocumentFileInfo requestedDoc, ClientContext clientContext) { try { var uploadLocation = string.Format("{0}{1}/{2}", SiteUrl, Helpers.ListNames.RequestedDocuments, Path.GetFileName(requestedDoc.DocumentWithFilePath)); //Get Document List var documentslist = clientContext.Web.Lists.GetByTitle(Helpers.ListNames.RequestedDocuments); var fileCreationInformation = new FileCreationInformation { Content = requestedDoc.ByteArray, Overwrite = true, Url = uploadLocation //Upload URL, }; var uploadFile = documentslist.RootFolder.Files.Add(fileCreationInformation); clientContext.Load(uploadFile); clientContext.ExecuteQuery(); var item = uploadFile.ListItemAllFields; item["Title"] = requestedDoc.FileNameParts.FileSubject; item["FileLeafRef"] = requestedDoc.SharepointFileName; item.Update(); } catch (Exception exception) { throw new ApplicationException(exception.Message); } return GetDocument(requestedDoc.SharepointFileName + "." + requestedDoc.FileNameParts.Extention, clientContext); }
EDIT: I found the following ms page regarding my problem (which seems to be identical to the problem they raised) http://support.microsoft.com/kb/2529243 , but there is no way to provide a solution.
source share