You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using the office365.sharepoint.files.file:open_binary method (or any method that calls this, like .read()) will raise an exception if the file name contains a character that should be encoded to make a safe URL.
e.g. file name "#123 Report" fails because of the # left in the URL by open_binary().
Suggestion:
Either the file.properties["ServerRelativeUrl"] should be encoded safely at point of ingestion
Or the URLs should be encoded before execution:
from urllib.parse import quote
@staticmethod
def open_binary(context, server_relative_url):
"""
Returns the file object located at the specified server-relative URL.
:type context: office365.sharepoint.client_context.ClientContext
:type server_relative_url: str
:return Response
"""
url = r"{0}/web/getFileByServerRelativePath(DecodedUrl='{1}')/\$value".format(
context.service_root_url(), server_relative_url
)
request = RequestOptions(quote(url, safe=':/')) <----- ADDED quote HERE
request.method = HttpMethod.Get
response = context.pending_request().execute_request_direct(request)
return response
```
The text was updated successfully, but these errors were encountered:
IMO a bug.
Using the office365.sharepoint.files.file:open_binary method (or any method that calls this, like .read()) will raise an exception if the file name contains a character that should be encoded to make a safe URL.
e.g. file name "#123 Report" fails because of the # left in the URL by open_binary().
Suggestion:
The text was updated successfully, but these errors were encountered: