0

Sharepoint online now allows # and % characters in filenames:

https://techcommunity.microsoft.com/t5/SharePoint-Blog/New-support-for-and-in-SharePoint-Online-and-OneDrive-for/ba-p/60357

Is it possible to retrieve a file like that using the sharepoint api?

Let's assume i have a file called test%file.pdf.

When making a request such as:

Request ->

https://mytestbed-my.sharepoint.com/personal/SOMEFAKEVALUE/_api/web/GetFileByServerRelativeUrl(@v)/$value?@v='/personal/SOMEFAKEVALUE/Documents/test%file.pdf'

I receive a response:

Response ->

{
  "error": {
    "code": "-1, Microsoft.SharePoint.Client.InvalidClientQueryException",
    "message": {
      "lang": "en-US",
      "value": "The query string \"serverRelativeUrl\" is missing or invalid."
    }
  }
}

Is there a specific way to escape this or is this not supported in the sharepoint api?

Thanks! Ruel Loehr

0

I haven’t tried it, but it could be because of two reasons.

  1. REST API are still not compatible with special characters in file name.
  2. You might need to encode your file path.

You can give a try to second option. Where you encode the Path of your file. In JavaScript we have two methods encodeURI and encodeURIComponent. You have to use encodeURIComponent function in order to encode the document path.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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