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
I find an issue when I try to use the method get_file_by_server_relative_path of this lib (Office365-REST-Python-Client]).
The connection to the sharepoint goes well, but when i try to get a file that I'm sure that is there, I get this error:
_office365.runtime.client_request_exception.ClientRequestException: ('-2130575338, Microsoft.SharePoint.SPException', 'Il file /sites/*******/_SALVA_APPOGGIO_OA/progettoOA.zip non esiste.', "404 Client Error: Not Found for url: https://*********.sharepoint.com/_api/Web/getFileByServerRelativePath(DecodedUrl='%2F*****%2F*******%2F*******%2F*******%2F_SALVA_APPOGGIO_OA%2FprogettoOA.zip')")
I used the code of the example reported on the lib (see lower), so I don't understand because the lib don't find the file that (as I wrote) I'm sure that exists in that path.
Someone can help me?
Thanks.
deftest_w_sp_py_lib(site_url, file_path, username, password):
fromoffice365.sharepoint.client_contextimportClientContext# , UserCredentialimporttempfilectx=ClientContext(site_url).with_user_credentials(username, password)
web=ctx.web.get().execute_query()
print(web.url)
file=ctx.web.get_file_by_server_relative_path(file_path).get().execute_query()
print("File size: ", file.length)
print("File name: ", file.name)
print("File url: ", file.serverRelativeUrl)
# download_path = Path(tempfile.mkdtemp()).joinpath(Path(file_path).name)# with open(download_path, "wb") as local_file:# file = (# ctx.web.get_file_by_server_relative_url(file_path)# .download(local_file)# .execute_query()# )# print(# f"'{file.server_relative_path}' file has been downloaded into {local_file.name}"# )
The text was updated successfully, but these errors were encountered:
And how You ca see from the error that i put on issue my path start with /sistes: "/sites/*******/_SALVA_APPOGGIO_OA/progettoOA.zip" (obviously the starts are putted by me to don't show th real path)
I find an issue when I try to use the method get_file_by_server_relative_path of this lib (Office365-REST-Python-Client]).
The connection to the sharepoint goes well, but when i try to get a file that I'm sure that is there, I get this error:
I used the code of the example reported on the lib (see lower), so I don't understand because the lib don't find the file that (as I wrote) I'm sure that exists in that path.
Someone can help me?
Thanks.
The text was updated successfully, but these errors were encountered: