-
-
Notifications
You must be signed in to change notification settings - Fork 371
Expand file tree
/
Copy pathcreate_page.py
More file actions
21 lines (17 loc) · 840 Bytes
/
create_page.py
File metadata and controls
21 lines (17 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
"""
Create OneNote pages
https://learn.microsoft.com/en-us/graph/api/resources/onenote
https://learn.microsoft.com/en-us/graph/onenote-create-page
"""
from office365.graph_client import GraphClient
from tests import test_client_id, test_password, test_tenant, test_username
client = GraphClient(tenant=test_tenant).with_username_and_password(test_client_id, test_username, test_password)
files = {}
with open("../data/Sample.html", "rb") as f, open("../data/office-logo-icon.jpg", "rb") as img_f, open(
"../data/Sample.pdf", "rb"
) as pdf_f, open("../data/SharePoint User Guide.docx", "rb") as word_f:
files["imageBlock1"] = img_f
files["fileBlock1"] = pdf_f
files["fileBlock2"] = word_f
page = client.me.onenote.pages.add(presentation_file=f, attachment_files=files).execute_query()
print(page.links.oneNoteWebUrl)