I was wondering if someone could help, or am I missing something. In the articles found here http://msdn.microsoft.com/en-us/library/office/dn450841(v=office.15).aspx#bk_FileStartUpload

They refer to using the /getfilebyserverrelativeurl. When I build my request and try and make a HttpWebRequest I get

The length of the URL for this request exceeds the configured maxUrlLength value

in the webresponse.

I'm making these requests from a console application against Office 365/SharePoint Online.

The url length is is 305 in this test case.

This is the code I am using

            HttpWebRequest request = HttpWebRequest.Create(resourceUrl) as HttpWebRequest;
            request.Credentials = _credentials;
            request.CookieContainer = _cookieContainter;
            request.Headers.Add("X-RequestDigest", _formDigest);
            request.Method = "POST";
            request.Timeout = 3600000;
            request.Accept = "application/json; odata=verbose";
            request.ContentLength = incomingStream.Length;
            request.AllowWriteStreamBuffering = false;
            request.KeepAlive = false;

            using (var reqStream = request.GetRequestStream()) {

            WebResponse response = request.GetResponse();
            using (System.IO.StreamReader sr = new System.IO.StreamReader(response.GetResponseStream())) {
                result = sr.ReadToEnd();

When its caught by the WebException and I read the exception response all I get is this "The length of the URL for this request exceeds the configured maxUrlLength value."

This is the resourceUrl:


  • 1
    Is your entire request URL longer than 2000 characters?
    – John-M
    Dec 19, 2014 at 15:13
  • Can you provide the code you are using?
    – wjervis
    Dec 19, 2014 at 15:20
  • Added more details to question.
    – Webfort
    Dec 20, 2014 at 16:39

3 Answers 3


Instead of


you can use

GetFileById or GetFolderById

To upload a new file, you can use the below url


Reference: http://msdn.microsoft.com/en-us/library/office/dn450841%28v=office.15%29.aspx

  • I've tried that. I've used that for other calls. Trying to get the file start upload to work which is the link in the question. Thanks
    – Webfort
    Dec 26, 2014 at 11:30

In case it helps, we had a similar (but not exact-same) situation. The URL parameters are not included in the length-restriction (at least not this restriction), so we changed our URL to be like so (to edit the original example) :


That appears to be working as expected.

Be aware of the 260 char max path limitation in general, though. If you try and add a file[name] to a folder and that total length exceeds the limit, you have a different problem with a known SP limitation.

Best of luck!


  • 3
    +1 for this answer - should be the marked answer.
    – thastark
    Apr 11, 2016 at 16:39
  • This is brilliant.
    – vinod
    Aug 18, 2016 at 22:55
  • Really awesome tricky logic you posted, many thanks to you Feb 1, 2017 at 7:00
  • Works with minimal changes to original code, nice!
    – Cardin
    Aug 30, 2019 at 1:39
  • you dah man user5346346436 Mar 3, 2021 at 3:44

Change the method from "GET" to "POST" and that will resolve the URL length issue.

  • In this case it needs to be a post.
    – Webfort
    Dec 20, 2014 at 16:40
  • then you have to include the urls in the body of the request not on the url itself. Mar 17, 2020 at 14:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.