-
-
Notifications
You must be signed in to change notification settings - Fork 369
Expand file tree
/
Copy pathcreate_wiki.py
More file actions
30 lines (20 loc) · 1.05 KB
/
Copy pathcreate_wiki.py
File metadata and controls
30 lines (20 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""
Demonstrates how to create and delete a wiki page in the default document library.
See https://learn.microsoft.com/en-us/sharepoint/dev/apis/rest-api/navigation/file-operations
"""
import argparse
from office365.sharepoint.client_context import ClientContext
from office365.sharepoint.pages.template_file_type import TemplateFileType
from tests.settings import client_id, password, site_url, tenant, username
def main():
parser = argparse.ArgumentParser(description="Create and delete a wiki page in the default document library")
parser.add_argument("--file-url", default="WikiPage 123.aspx", help="wiki page file name")
args = parser.parse_args()
ctx = ClientContext(site_url).with_username_and_password(
tenant=tenant, client_id=client_id, username=username, password=password
)
parent_folder = ctx.web.default_document_library().root_folder
file = parent_folder.files.add_template_file(args.file_url, TemplateFileType.WikiPage).execute_query()
file.delete_object().execute_query()
if __name__ == "__main__":
main()