-
-
Notifications
You must be signed in to change notification settings - Fork 370
Expand file tree
/
Copy pathget_task_details.py
More file actions
31 lines (23 loc) · 1.01 KB
/
Copy pathget_task_details.py
File metadata and controls
31 lines (23 loc) · 1.01 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
31
"""
Get planner task details (description, checklist, references, preview type).
Requires delegated permission ``Group.ReadWrite.All``.
https://learn.microsoft.com/en-us/graph/api/planner-get-taskdetails?view=graph-rest-1.0
"""
import sys
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)
group = client.groups.get_by_name("My Sample Team").get().execute_query()
plans = group.planner.plans.get().execute_query()
if len(plans) == 0:
sys.exit("No plans were found")
tasks = plans[0].tasks.get().execute_query()
if len(tasks) == 0:
sys.exit("No tasks were found")
task = tasks[0]
details = task.details.get().execute_query()
print(f"Task: {task.title}")
print(f" Description: {details.description}")
print(f" Preview type: {details.preview_type}")
if details.checklist:
print(f" Checklist items: {len(list(details.checklist))}")