Sharepoint 2010 客户端对象模型 - 上传文档(409 冲突) [英] Sharepoint 2010 Client Object Model - Upload Document (409 Conflict)

查看:49
本文介绍了Sharepoint 2010 客户端对象模型 - 上传文档(409 冲突)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 SP2010 客户端对象模型上传到文档库,遵循 Microsoft 此处的指导:http://msdn.microsoft.com/en-us/library/ee956524.aspx#SP2010ClientOMOpenXml_Uploading

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#SP2010ClientOMOpenXml_Uploading

我在执行以下代码时遇到了 HTTP 409(冲突)状态代码.

I am facing an HTTP 409 (Conflict) status code when executing the following code.

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

我做错了什么?

推荐答案

这里的问题是我上传的站点是一个子站点,而不是 sharepoint 的根.我不知道这是否是设计"选择,但似乎您必须为 ClientContext 使用 sharepoint 的根,至少在这种特殊情况下是这样.

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.

工作代码:

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);
} 

这篇关于Sharepoint 2010 客户端对象模型 - 上传文档(409 冲突)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆