Skip to content

Fixed escaping server relative URLs#359

Merged
vgrem merged 1 commit intovgrem:masterfrom
Archdesk:fix/sharepoint-server-relative-url-escaping
Apr 20, 2026
Merged

Fixed escaping server relative URLs#359
vgrem merged 1 commit intovgrem:masterfrom
Archdesk:fix/sharepoint-server-relative-url-escaping

Conversation

@jerry-sky
Copy link
Copy Markdown
Contributor

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
@vgrem vgrem merged commit a168264 into vgrem:master Apr 20, 2026
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.

2 participants