Skip to content

Conversation

@jerry-sky
Copy link

Given value that is a path, like /sites/Site/O'Reilly, needs to be enclosed within quotes:

GET https://{site_url}/_api/web/GetFolderByServerRelativeUrl('/sites/Site/O'Reilly')/Files

because the quote within the name of the folder O'Reilly is messing up where the argument ends,
it needs to be escaped, like so:

GET https://{site_url}/_api/web/GetFolderByServerRelativeUrl('/sites/Site/O''Reilly')/Files

before sending it to the API.

rawurlencodeing it doesn't solve the issue, the URL is decoded before it is evaluated by the API it seems.


Example error when you don't escape the quote characters:

{
  "error": {
    "code": "-1, Microsoft.SharePoint.Client.InvalidClientQueryException",
    "message": {
      "lang": "en-US",
      "value": "The expression \"Web/getFolderByServerRelativeUrl('/sites/Site/O'Reilly')\" is not valid."
    }
  }
}

Sources:

@jerry-sky jerry-sky changed the title fixed escaping server relative URLs Fixed escaping server relative URLs Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant