msgraph-sdk-python icon indicating copy to clipboard operation
msgraph-sdk-python copied to clipboard

JSON serialization exception when creating PlannerTask

Open Spaider opened this issue 1 year ago • 3 comments

Sample Python code from this documentation page does not work if any of datetime-typed fields initialized. Exception with message Object of type DateTime is not JSON serializable is thrown.

Non-working code:

graph_client = GraphServiceClient(credentials, scopes)

request_body = PlannerTask(
	plan_id = "xqQg5FS2LkCp935s-FIFm2QAFkHM",
	bucket_id = "hsOf2dhOJkqyYYZEtdzDe2QAIUCR",
	title = "Update client list",
	assignments = PlannerAssignments(
		additional_data = {
				"fbab97d0-4932-4511-b675-204639209557" : {
						"@odata_type" : "#microsoft.graph.plannerAssignment",
						"order_hint" : " !",
				},
		}
	),
	due_date_time = datetime(2023, 12, 31)         
)

result = await graph_client.planner.tasks.post(request_body)

Spaider avatar Dec 19 '23 18:12 Spaider