Sharepoint 2010 Client Object Model - Upload Document (409 Conflict)

前端 未结 4 1140
花落未央
花落未央 2021-02-04 16:53

I am using the SP2010 Client Object Model to upload to a document library, following the lead from Microsoft here: http://msdn.microsoft.com/en-us/library/ee956524.aspx#SP2010Cl

4条回答
  •  被撕碎了的回忆
    2021-02-04 17:27

    The issue here was that the site I am uploading to is a subsite, not the root of sharepoint. I don't know if this was a "design" choice or not, but it seems you have to use the root of sharepoint for the ClientContext, at least in this particular case.

    Working code:

    var clientContext = new ClientContext("http://myservername") { Credentials = LogonCredentials };
    using (var fileStream = new FileStream(@"C:\Temp\Test.txt", FileMode.Open))
    {
           Microsoft.SharePoint.Client.File.SaveBinaryDirect(clientContext, "/sites/subsitename/MyDocLibraryName/Test_FromClientOM.txt", fileStream, true);
    } 
    

提交回复
热议问题