Office365-REST-Python-Client | Sharepoint | Download files | 404 File does not exists
See original GitHub issueHi,
I have properly created an App, generated client credentials, and trusted the app for my SharePoint online site.
I have created a file test.txt and it is placed under -https://company.sharepoint.com/sites/VILASCA/Shared Documents/General/test.txt
Installed the latest version of the module
pip freeze | grep Office
Office365-REST-Python-Client==2.3.11
class SharePoint:
def __init__(self):
context_auth = AuthenticationContext(Configs.SITE_URL) ---> SITE_URL='https://company.sharepoint.com/sites/VILASCA/'
context_auth.acquire_token_for_app(client_id=Configs.OAUTH_CLIENT_ID, client_secret=Configs.OAUTH_CLIENT_SECRET)
self.ctx = ClientContext(Configs.SITE_URL, context_auth)
def download_files(self):
file_url = "/sites/VILASCA/Shared%20Documents/General/test.txt"
download_path = os.path.join(tempfile.mkdtemp(), os.path.basename(file_url))
print(download_path)
with open(download_path, "wb") as local_file:
file = self.ctx.web.get_file_by_server_relative_url(file_url).download(local_file).execute_query()
print("[Ok] file has been downloaded into: {0}".format(download_path))
if __name__ == '__main__':
s = SharePoint()
s.download_files()
However, it throws an error, not able to get my head around this.
office365.runtime.client_request_exception.ClientRequestException: ('-2130575338, Microsoft.SharePoint.SPException', 'The file /sites/VILASCA/Shared%20Documents/General/test.txt does not exist.', "404 Client Error: Not Found for url: https://company.sharepoint.com/sites/VILASCA/_api/Web/getFileByServerRelativeUrl('%2Fsites%2FVILASCA%2FShared%2520Documents%2FGeneral%2Ftest.txt')?$select=ServerRelativePath")
Issue Analytics
- State:
- Created a year ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
Download File - Does Not Exist · Issue #346 - GitHub
from office365.sharepoint.files.file import File from office365.sharepoint.client_context import ClientContext, ClientCredential main_url: ...
Read more >Downloading Sharepoint file with Office365-REST-Python ...
Good morning. The problem was in the url of my sharepoint passed to. ctx = ClientContext(url).with_user_credentials(username, password).
Read more >404 FILE NOT FOUND - When I attempt to open Sharepoint Site
We understand that all the files are missing from your SharePoint online site document library. We'll try our best to help you find...
Read more >Sharepoint site shows 404 FILE NOT FOUND
Hi Michel,. If the 404 error message occur when you click on the SharePoint icon, this might be caused the SharePoint root site...
Read more >Sharepoint 404 Not found but empty file is created
The flow fails at the 'Create file' step with a 404 file not. ... where the Folder path does not exist, instead of...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Found the issue. I have put improper scope. Thank you.
Good catch and good to know! 👍
In case if someone else will stumble upon this issue, the list of supported scopes could be found here ( Table 1. SharePoint add-in permission request scope URIs and descriptions)