'503 Server Error: Service Unavailable' while downloading large folder using Office365 API

Copper Contributor


I have created a python script that uses Office365 API to download an entire folder from Sharepoint, zip it and store it on my machine. The script works completely fine for smaller folders, however if I try to download larger folders (3GB+ size), I get this error: 


raise ClientRequestException(*e.args, response=e.response)
office365.runtime.client_request_exception.ClientRequestException: (None, None, "503 Server Error: Service Unavailable for url: https://mySite.sharepoint.com/sites/somesite/_api/Web/getFolderByServerRelativeUrl('Shared%2520Documents%2FmyFolder')/Folders")


 This is how I am getting the list of folders:


def get_folder_list(folder_name):
    target_folder_url = f'{SHAREPOINT_DOC}/{folder_name}'
    root_folder = ctx.web.get_folder_by_server_relative_url(target_folder_url)
    folders_list = root_folder.folders.get().execute_query()
    return folders_list


The error is thrown on the execute_query line [Line 3 here].

As stated, the code works fine for smaller files but fails for larger ones. How do I resolve this such that the entire larger folder (along with its nested sub-folders) gets downloaded too.

0 Replies