microsoftgraph / microsoftgraph/msgraph-sdk-python

JSON serialization exception when creating PlannerTask

Open
#534 3 comments 0 reactions 1 assignee View on GitHub

@rkodev is already working on this.

Since Jul 12, 2024.

Needs: Attention :wave:
Dominant language
Python
Stars
630
Forks
96
Avg merge
15h 20m
Merged PRs (30d)
3

Description

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)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.