sharepoint API
3 TopicsDownload file from SharePoint via API using Python
i am am facing 404 error while downloading file from SharePoint via Rest API using Python. Below is my code: from office365.runtime.auth.client_credential import ClientCredential from office365.sharepoint.client_context import ClientContext def get_share_point_context () : sharepoint_url = "https://xxxx.sharepoint.com" client_id = 'yyyy' client_scret = 'zzzz' ctx = ClientContext(sharepoint_url).with_client_credentials(client_secret=client_scret,client_id=client_id) file_relative_url = "/sites/aaa/Bl_Upload_test/resume.txt" file = ctx.web.get_folder_by_server_relative_path(decoded_url=file_relative_url) ctx.load(file) ctx.execute_query() with open('downlaoded_file.txt', 'wb') as f: file.download() get_share_point_context() Below is the error: C:\Users\se\PycharmProjects\10135\venv\Scripts\python.exe C:\Users\se\PycharmProjects\10135\sharepoint_file_download.py Traceback (most recent call last): File "C:\Users\se\PycharmProjects\10135\venv\lib\site-packages\office365\runtime\client_request.py", line 38, in execute_query response.raise_for_status() File "C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\site-packages\requests\models.py", line 1021, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://xxxx.sharepoint.com/_api/Web/getFolderByServerRelativePath(DecodedUrl='%2Fsites%2Frpa%2FBl_Upload_test%2Fresume.txt') During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\Users\se\PycharmProjects\10135\sharepoint_file_download.py", line 16, in <module> get_share_point_context() File "C:\Users\se\PycharmProjects\10135\sharepoint_file_download.py", line 12, in get_share_point_context ctx.execute_query() File "C:\Users\se\PycharmProjects\10135\venv\lib\site-packages\office365\runtime\client_runtime_context.py", line 191, in execute_query self.pending_request().execute_query(qry) File "C:\Users\se\PycharmProjects\10135\venv\lib\site-packages\office365\runtime\client_request.py", line 42, in execute_query raise ClientRequestException(*e.args, response=e.response) office365.runtime.client_request_exception.ClientRequestException: ('-2147024894, System.IO.FileNotFoundException', 'File Not Found.', "404 Client Error: Not Found for url: https://xxxx.sharepoint.com/_api/Web/getFolderByServerRelativePath(DecodedUrl='%2Fsites%2Frpa%2FBl_Upload_test%2Fresume.txt')") Process finished with exit code 1 but I do have a file resume.txt, and it resides in the site content -> document library named Bl_Upload. I have tried to search many related posts in internet about this problem. Many talks about file naming and special characters, some talks about authentication. So far there is no luck in locating a similar problem. Any help would be appreciated.7.2KViews0likes0CommentsNeed help regarding the Sharepoint API's
Hi, I am working on the sharepoint API's however currently stuck in middle of the code, I am not able to find the some of the sharepoint API's that will resolve my issue Currently I am looking for the sharepoint API that can :- 1. Provide me all the groups of which the user is part of 2. And inside library permissions we have a setting to disable library data from appearing in Search, (Below mention is the screenshot of the search option for which I am looking the API for it )894Views0likes1CommentOffice365-rest-python-client
Hello, I am trying to access an excel spreadsheet into my python script using office365-rest-python-client using both my user credentials and client credentials. My SharePoint site URL is: https://tenant/sites/mysite/file. I have access to input file and client id and secret for site and subsite in which my file is but don't have access to the folder in which the input file is. I am getting invalid DNS errors and unable to acquire token errors. Anybody have any suggestions with this?2.1KViews0likes0Comments