Changelog
List of changes:
- #234: determines if security validation expired and refresh if expired for SharePoint client
- SharePoint API enhanced support for
publishing
&webhooks
namespaces - Planner API model has been updated
- Outlook API enhancements, namely the support for download MIME content of a message
SharePoint API: create a Site Page
The example demonstrates how to create a Site Page
ctx = ClientContext(team_site_url).with_credentials(client_credentials)
new_page = ctx.site_pages.pages.add()
new_page.save_draft(title="My news page")
new_page.publish().execute_query()
SharePoint API: create a new webhook
The example demonstrates how to create a webhook to SharePoint list:
ctx = ClientContext(site_url).with_credentials(client_credentials)
push_service_url = "https://westeurope0.pushnp.svc.ms/notifications?token=526a9d28-d4ec-45b7-81b9-4e1599524784"
target_list = client.web.lists.get_by_title("Documents")
subscription = target_list.subscriptions.add(push_service_url).execute_query()
where
push_service_url - your service endpoint URL. SharePoint sends an HTTP POST to this endpoint when events occur in the specified resource
Refer Overview of SharePoint webhooks for a details.
Planner API: create a task (Create plannerTask
endpoint)
from office365.graph_client import GraphClient
client = GraphClient(acquire_token_func)
plan = ensure_plan(client.me.planner, "My plan")
task = client.planner.tasks.add(title="New task", planId=plan.id).execute_query()
Outlook API: download MIME content of a message (Get MIME content of a message
endpoint)
The example demonstrates how to download an Outlook message body in MIME format and save into a file:
client = GraphClient(acquire_token_func)
# requires Mail.ReadWrite permission
user = client.users[test_user_principal_name]
messages = user.messages.select(["id"]).top(10).get().execute_query()
with tempfile.TemporaryDirectory() as local_path:
for message in messages: # type: Message
with open(os.path.join(local_path, message.id + ".eml"), 'wb') as local_file:
message.download(local_file).execute_query() # download MIME representation of a message