Sharepoint 2013 rest space problem


  • hi all,

    i am copying file from folder of one document library to another folder. i had success with that. my problem is that when filename has space in filename it add %20 to it. then file is not copied to another doc lib folder and give error file not found. please help with this.

    Sunday, August 31, 2014 12:18 PM


All replies

  • Hi

    Are you copying from explorer itself or directly in sharepoint? the %20 is for adding a space.

    Hope this helps. Please remember to click “Mark as Answer” on the post that helps you, and to click “Unmark as Answer” if a marked post does not actually answer your question. This can be beneficial to other community members reading the thread.

    Sunday, August 31, 2014 2:21 PM
  • hi Ed,

    i am copying file from folder of one document library to folder of document library. basically i am using copyTo function of rest and below is my URL

    var sourceRelativeUrl = "/sites/testsite" + libraryName + "/" + oldfolderName + "/" + fileName;
    var destRelativeUrl = "/sites/testsite/" + libraryName + "/" + newfolderName + "/" + fileName;
    url_to_Copy = _spPageContextInfo.webAbsoluteUrl + "/_api/web/getfilebyserverrelativeurl('" + sourceRelativeUrl + "')/copyto(strnewurl='" + destRelativeUrl + "',boverwrite=false)"

    when i send filename which contains spaces it throw me error file name does not exits.

    can you please help me regarding this.

    Sunday, August 31, 2014 5:41 PM
  • Have you tried escaping the whitespace in the file name/path?  %20 is an encoded reference to a blank space.  I.e. "http://server/sites/document library" enclosed in quotes will be handled as expected, unless escaped it will be read as http://server/sites/document%20library.
    Sunday, August 31, 2014 6:20 PM
  • Hello Bill,

    First of all I am great fan of your blogs. I read almost all you blogs on TechNet. I am not trying to escape any white space in the file name. 

    I have filename as "RE [REG113050710419113] Steps taken to resolve the issue", the REST url generated for filename is as below


    Then it give me error as the length of the URL for this request exceeds the configured maxUrlLength value or File does not exist.

    Please help with this issue.

    As i am using office 365 so not able to increase max URL length. Also I am not able to change filename or remove white space as main requirement of client is not to change file name.

    Sunday, August 31, 2014 7:03 PM
  • Hi,

    You can run into issues when the URL becomes to large. More details about the exact limits can be found here, but as a best practice try to keep the URL length of a document under 260 characters.

    More information is here:

    Best Regards

    Dennis Guo
    TechNet Community Support

    Monday, September 01, 2014 9:37 AM