Office365-REST-Python-Client
Office365-REST-Python-Client copied to clipboard
How to download a folder from onedrive for business (sharepoint site)
I am trying to download a folder from a specific site on sharepoint that we sync via our onedrive for business.
if I try to access the folder via the sharepoint webinterface the link looks like this:
https://mycompany.sharepoint.com/sites/SalesTeam/Shared%20Documents/Forms/AllItems.aspx?viewid=<the_view_id>&id=%2Fsites%SalesTeam%2FShared%20Documents%2FGeneral%2FSales%2FSales%20Documents
I tried to get the folder the following way but it shows an error "'List' object has no attribute 'root_folder'".
How to download the whole content of the "Sales Documents" folder?
def download_folder(self,title,local_path=None):
ctx = self.ctx
list_object = ctx.web.lists.get_by_title(title)
folder = list_object.root_folder
ctx.load(folder)
ctx.execute_query()
folders = folder.folders
ctx.load(folders)
ctx.execute_query()
for myfolder in folders:
print(f'File name: {myfolder.properties["Name"]}')
return "download_path"