Demonstrates how to delete all list items in a list
Reference
View source
from office365.sharepoint.client_context import ClientContext
from tests.settings import cert_path, cert_thumbprint, client_id, site_url, tenant
def print_progress(items_count: int) -> None:
print("List items count: {0}".format(target_list.item_count))
ctx = ClientContext(site_url).with_client_certificate(
tenant, client_id=client_id, thumbprint=cert_thumbprint, cert_path=cert_path
)
target_list = ctx.web.lists.get_by_title("Company Tasks")
target_list.clear().execute_batch()
print(f"List items count: {target_list.item_count}")
← Back to Lists