Office365-REST-Python-Client icon indicating copy to clipboard operation
Office365-REST-Python-Client copied to clipboard

Issue with Downloading Files Using Custom URL Format

Open dtdat1997 opened this issue 8 months ago • 1 comments

Hi everyone, I am encountering an issue when using the file download function in the following examples:

https://github.com/vgrem/Office365-REST-Python-Client/blob/master/examples/sharepoint/files/download.py https://github.com/vgrem/Office365-REST-Python-Client/blob/master/examples/sharepoint/files/download_from_url.py

These functions work perfectly with file paths in the format:

"{site_url}/sites/team/Shared Documents/archive/big_buck_bunny.mp4" "Shared Documents/archive/big_buck_bunny.mp4"

However, they do not work with the following format:

https://tenant.sharepoint.com/:p:/r/sites/sitecollection/_layouts/15/Doc.aspx?sourcedoc=yyyyyy&file=newfilename.pptx

Does the library support downloading files with this link format, or is there a way to convert this URL into a valid file path that will work with the current implementation?

Thank you so much for your help!

dtdat1997 avatar Apr 01 '25 12:04 dtdat1997

I would like to bump this question, I also did encounter it and it does produce an error like:

('-2130575338, Microsoft.SharePoint.SPException', 'File /sites//Shared Documents/123.xlsx does not exists.', "404 Client Error: Not Found for url: https://.sharepoint.com/sites/<site_name>/_api/Web/getFileByServerRelativePath(DecodedUrl='%2Fsites%2F<site_name>%2F%2FShared%20Documents%2F123.xlsx')")

also, it is possible to list elements in the Shared Documents, but it appears empty (and files are there)

WojciechBuda88 avatar May 08 '25 10:05 WojciechBuda88