Office365-rest-python-client: Single quote in file names is causing problems if trying to download file

Created on 17 Sep 2020  ·  4Comments  ·  Source: vgrem/Office365-REST-Python-Client

Hi,

It seems that I am getting an error if I am trying to download a file with a name containing single quote(s).

office365.runtime.client_request_exception.ClientRequestException: ('-1, Microsoft.SharePoint.Client.InvalidClientQueryException', 'The expression "Web/getFileByServerRelativeUrl('/sites/mysite/mypath/Update Q1'2020.pptx')/$value" is not valid.', "400 Client Error: Bad Request for url: https://tennant.sharepoint.com/sites/mysite/_api/Web/getFileByServerRelativeUrl('/sites/mysite/Shared%20Documents/mypath/Update%20Q1'2020.pptx')/%5C$value")

It seems that the single quote is not escaped here: %27 instead of '.
It works for all other files, this is the only one which is causing an error. Renaming the file seems to fix it, but it needs to be fixed here I would assume.

bug

All 4 comments

Fixed in #300

@vgrem remember to close this bug, as this is fixed in #300 :)

Single quotes in that context, should be escaped by using double single quotes: '' (not "), which the patch takes care of.

@kraptor we will, as long the new version will be released, thanks for the fix!

@florinmihut and @kraptor thank you for catching this issue and resolving it.

It should no longer occur in the latest release.

Was this page helpful?
0 / 5 - 0 ratings