I'm using the SharePoint online REST API. Things generally work fine, but I'm failing to figure out how to get information about a file (document) that contains a quote in its name. Here's my REST call:

https://mysite.sharepoint.com/_api/Web/getfilebyserverrelativeurl("/Shared Documents/Roy's quoted doc.txt")

The response I'm getting is '400 Bad Request', with the error being "The expression "Web/getfilebyserverrelativeurl("/Shared Documents/Roy's quoted doc.txt")" is not valid."

I've tried all sorts of tricks with encoding the path (%27 encoding for the quote sign, backslashing the quote, etc.), but failed to figure out the right one.

Is there any kind of encoding I'm not aware of?

up vote 9 down vote accepted

Try putting extra apostrophe. That is, use Web/getfilebyserverrelativeurl("/Shared Documents/Roy''s quoted doc.txt")

  • 1
    Seems to be working - thanks! – Roy2012 Sep 2 '15 at 5:47

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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