48

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

GR7
  • 5,083
  • 8
  • 48
  • 66

10 Answers10

37

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.

Community
  • 1
  • 1
GR7
  • 5,083
  • 8
  • 48
  • 66
5

At times the error code 409 occurs when you name you folder or files a reserved or blocked name. These could be names like register, contact

In my case I named a folder contact, turns out the name was blocked from being used as folder names.

When testing my script on postman, I was getting this error:

<script>
    document.cookie = "humans_21909=1"; document.location.reload(true)
</script>

I changed the folder name from contact to contacts and it worked. The error was gone.

David Kariuki
  • 1,522
  • 1
  • 15
  • 30
3

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";
skzi
  • 340
  • 3
  • 14
3

We are also getting the same error while we are trying to access a same resource with in milliseconds. Like if i try to POST some data to www.abc.com/blog and with in milliseconds an other request will also go for the same resource i.e. www.abc.com/blog from the same user. So it'll give the 409 error.

2

I encountered similar issue when uploading a file returned 409.

Besides issues mentioned above it can also happen due to file size restrictions for POST on the server side. For example, tomcat (java web server) have POST size limit of 2MB by default.

VinPro
  • 882
  • 1
  • 6
  • 10
2

I got this error when tried to create folder http://localhost:8080/repository/default/parent/newFolder when http://localhost:8080/repository/default/parent didn't exist.

0

Its because of wrong path provided. It may be that the url contains space and if the case url has to be properly constructed.

The correct url should be in the format with file name included like "http://server name/document library name/new file name"

So if report.xlsx is the file that has to be uploaded at "http://server name/Team/Dev Team" then path comes out to be is "http://server name/Team/Dev Team/report.xlsx". It contains space so it should be reconstructed as "http://server name/Team/Dev%20Team/report.xlsx" and should be used.

Abdullah Imran
  • 259
  • 3
  • 13
0

I ran into this issue several times for different reasons. I'll list some of them here.

  1. The Chrome browser is caching the request. You can disable this in the chrome developer console or in the code use the header {cache: 'no-cache'}

  2. The nested folder path does not exist when putting the file. Make sure the folder exists first, before putting the file into the nested folder.

  3. Both the new file and the old file content are (about) the same, as well as the commit message. Just change the commit message to be more randomised. Use something like this in the commit message.

     const date = new Date()
     const timeStampHash = `${date.toISOString()}-${Math.floor(Math.random() * 1000)}`
     const commitMsg = `Commited from my App: #${timestampHash}`
     
stanley_manley
  • 195
  • 3
  • 9
-1

I is because you are using predefined variables to naming your filename. change your filename from e.g register.asp to registerUser.asp. That will solve your issue

Daniel Nyamasyo
  • 2,152
  • 1
  • 24
  • 23
-1

please rename your file or folder name of API like- xyz.com/register.php rename it xyz.com/myregister.php

some name, keyword is blocked on getting this error