The remote server returned an error: (412) PRECONDITION FAILED RRS feed

  • Question

  • I'm programatically uploading a file to sharepoint and, once in a while, I get this error:

    System.Net.WebException: The remote server returned an error: (412) PRECONDITION FAILED

    Does anybody know how to solve this?  here's the code.

                        Uri destUri = new Uri(SharepointURL.ToString());
                        WebRequest req = WebRequest.Create(destUri);
                        Stream outStream = default(Stream);
                        req.Method = "PUT";
                        req.Headers.Add("Overwrite", "T");
                        req.Timeout = System.Threading.Timeout.Infinite;
                        req.Credentials = new NetworkCredential("myUser", "MyPassword");
                        outStream = req.GetRequestStream();

    Or does anybody have another simple way to upload a file to sharepoint (I tried using the microsoft.sharepoint.dll but I couldn't figure out how to pass credentials to use)

    Tuesday, June 23, 2009 8:59 PM

All replies

  • I have deleted the reply you made to an ancient (almost 2 years old) thread with the same subject.

    Either start a new thread of your own (which enables you to give exactly your situation and thus is usually better) 

    OR reply to an existing thread (typically only worthwhile if a recent thread as otherwise the environment (SPs etc.) will have changed)

    but don't do both as it only causes unnecessary duplication of effort.


    WSS FAQ sites: and
    Total list of WSS 3.0 / MOSS 2007 Books (including foreign language)
    Wednesday, June 24, 2009 4:12 AM
  • Hi

    Well, this thread has 2 entry points, in my case I can talk about both:

    First, To Mike. Some times we have an issue or question and we found a thread and we not always see the dates and wey say, hey! I have a similar question but the answer does not work for us and then someone could say to us, make a new thread! and we do.

    Second. I have a similar issue I got this message-->Failed to load resource: the server responded with a status of 412 ()

    It suppouse to be an Add In that I want to add to a workbook in Excel 365 ... this is the add in


    First, as I do not have a server, I use the Sharepoint 365 to publish the code files, but as a Genius forbidden the javascrip code then The code does not run. So, I put the files in sharepoint 2010 And then, it loads but in Internet Explorer 11 just break, so, as nothing works with IE11 and Office365, then I use Google Chrome and do not break but it shows the Error 412.

    Notice that the Add In main page Opens and works by itself. But in Excel 365 just does not work.

    Why forbbiden the javascript code? for security? we know the financial and all others reasons... Also you forbbiden the vbscript code.. What happened to you?... any way.. Sharepoint 365 with out customizable code its only a big and expensive shared folder.

    yea!! a lot of threads in one single issue.

    • Edited by Rictro Saturday, July 20, 2019 5:51 PM wording
    Saturday, July 20, 2019 5:31 PM