上传文件使用.NET的WebRequest到SharePoint时,原因为409 /冲突HTTP错误?上传文件、冲突、错误、NET

2023-09-04 01:08:05 作者:小野猫

我有一个使用的WebRequest将文件上载到SharePoint 2010列表/文件夹,使用PUT请求的方法,与覆盖标题设置为T(覆盖)。

I've got a method that uses a WebRequest to upload a file to a sharepoint 2010 list/folder, using a PUT request, with the Overwrite Header set to T (overwrite).

当多个文件上传(方法被调用多次),一些请求失败,出现一个409的冲突HTTP错误。

When several files are uploaded (method is called several times), some requests fail with a 409 Conflict HTTP error.

我GOOGLE了,这似乎是最常见的原因是试图影响/更新不存在(比如设置请求URL的路径下的文件名)的文件。然而,事实并非如此。如果冲突有一些东西需要与该文件已经存在,我增加了code上传之前物理删除的文件,我仍然得到一些409的。

I've googled, and it seems the most common reason is trying to affect/update a file that does not exist (like setting the request URL to a path without a file name). However, that is not the case. In case the conflict had something to do with the file already existing, I added code to physically delete the file before uploading it, and i'm still getting some 409's.

有没有人收到这种类型的错误,如果是这样,你能告诉我你是怎么固定它,什么是根本原因?任何帮助是极大的AP preciated。谢谢

Has anyone received this type of error, and if so, can you tell me how you fixed it and what was the root cause? Any help is greatly appreciated. Thanks

推荐答案

由于没有答案被张贴,我发现下面的这里:

Since no answers were posted, I found the following here:

Web服务器(运行网站)认为,提交客户端的请求(如Web浏览器或我们的CheckUpDown机器人)无法完成,因为它与已建立的一些规则冲突。例如,您可能会如果您尝试上传文件是超过一个已经存在的Web服务器得到一个409错误 - 导致了版本控制冲突

The Web server (running the Web site) thinks that the request submitted by the client (e.g. your Web browser or our CheckUpDown robot) can not be completed because it conflicts with some rule already established. For example, you may get a 409 error if you try to upload a file to the Web server which is older than the one already there - resulting in a version control conflict.

有人在similar这里的计算器的问题时说,答案是:

Someone on a similar question right here on stackoverflow, said the answer was:

我有,当我引用文档的URL这个问题   库而不是目标文件本身。

I've had this issue when I was referencing the url of the document library and not the destination file itself.

即。尝试的http://服务器名称/文档库名称/新文件name.doc

但我100%肯定这不是我的情况,因为我检查的WebRequest的URI属性几次和URI是完整的文件名和路径中的所有文件夹存在于SharePoint网站。

However I am 100% sure this was not my case, since I checked the WebRequest's URI property several times and the URI was complete with filename, and all the folders in the path existed on the sharepoint site.

不管怎么说,我希望这可以帮助别人。

Anyways, I hope this helps someone.