Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reasons for a 409/Conflict HTTP error when uploading a file to sharepoint using a .NET WebRequest?

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).

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

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.

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

like image 625
GR7 Avatar asked Jul 22 '11 02:07

GR7


People also ask

How do I resolve 409 conflict error?

If the server notices a conflict between the HTTP request and the resource, it will display a “409 Conflict” error. Although this scenario can be frustrating, you can easily fix the 409 error. On the client side, you can fix typos in the requested URL, clear your browser cache, and uninstall browser extensions.

What causes a 409 error?

The HTTP 409 Conflict response status code indicates a request conflict with the current state of the target resource. Conflicts are most likely to occur in response to a PUT request.

What does 409 Forbidden mean?

The request could not be completed due to a conflict with the current state of the target resource. This code is used in situations where the user might be able to resolve the conflict and resubmit the request.


2 Answers

I found 2 things worth mentioning while uploading files using webdav and http web request. First, for the provider I was using, I had to append the filename at the end of the provider url. Ihad to append the port number in the url. And I also set the Request method to PUT instead of POST.

example:

string webdavUrl = "https://localhost:443/downloads/test.pdf"; request.Method = "PUT"; 
like image 24
sk1900 Avatar answered Sep 22 '22 00:09

sk1900


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

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.

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

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

i.e. try http://server name/document library name/new file name.doc

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.

like image 114
GR7 Avatar answered Sep 22 '22 00:09

GR7