Unable to download file 404 Client Error: Not Found for url
I am attempting to download an Excel document from SharePoint
office365.runtime.client_request_exception.ClientRequestException: ('-2130575338, Microsoft.SharePoint.SPException', 'The file /sites/name1/Name name-2/name3/Name 4 - name/Test.xlsx' does not exist.', "404 Client Error: Not Found for url: https://company.sharepoint.com/sites/name1/_api/Web/getFileByServerRelativeUrl('%2Fsites...Test.xlsx')?$select=ServerRelativePath")
import os import tempfile from office365.runtime.auth.user_credential import UserCredential from office365.sharepoint.client_context import ClientContext from office365.sharepoint.files.file import File site_url = "https://company.sharepoint.com/sites/name1" ctx = ClientContext(site_url).with_credentials(UserCredential("[email protected]", "pass")) file_url = 'https://company.sharepoint.com/sites/name1/Name name-2/name3/Name 4 - name/Test.xlsx' download_path = os.path.join(tempfile.mkdtemp(), os.path.basename(file_url)) with open(download_path, "wb") as local_file: file = File.from_url(file_url).with_credentials(UserCredential("[email protected]", "pass")).download(local_file).execute_query()
print("[Ok] file has been downloaded into: {0}".format(download_path))
@Nickl55 did you figure out a way to debug this?