Adding a Full Task [PlannerTask] to 365 planner

Today i created an angular app to interact with MS 365 Planner. I tried to add a task. The example @MS - create task works fine
  "planId": "xqQg5FS2LkCp935s-FIFm2QAFkHM",
  "bucketId": "hsOf2dhOJkqyYYZEtdzDe2QAIUCR",
  "title": "Update client list",
  "assignments": {
    "fbab97d0-4932-4511-b675-204639209557": {
      "@odata.type": "#microsoft.graph.plannerAssignment",
      "orderHint": " !"

Adding a details object was great until i was trying to add some checklist items.
My app gave this error [400]:

message:"Schema validation has failed. Validation for field 'Title', on entity 'Task' has failed: A non-null value must be specified for this field."

Well, this is the end of the story, since after everything went well in the Graph Explorer my app still gave the same error, until i notices that the Content-Type was application/x-www-form-urlencoded.

The Fix is
.header('Content-Type', 'application/json')

While the Graph Explorer gave this error [400]:

message:"The Request is invalid. Value cannot be null. Parameter name: qualifiedName."

Traveling through the MS DOCS from Task Type to Task Details to PlannerCheckListItems i saw they add to some types the @odata.type
"@odata.type": "microsoft.graph.checklistItem", // required in PATCH requests to edit the checklist on a task
So i added that to the checklistItem field ... and got this error [400]

message:"The Request is invalid. A type named 'microsoft.graph.checklistItem' could not be resolved by the model. When a model is available, each type name must resolve to a valid type ."

Googling that resulted with some Sharepoint Errors of the name like this one, and knowing Sharepoint and Microsoft i was sure its the same idea, the error basically means that the type you sent is not the right type, and with MS it's just some extra words or chars.

with the help of the Graph Explorer querying a Task Details like this [planner/tasks/<task_id>/details] i saw that the @odata.type for CheckListItems is actually "#microsoft.graph.plannerChecklistItem", planner before..

AND... Almost...
the CheckList wasn't actually created.. you must, after creating the task, GET the task's details, get the @odata.etag, and PATCH it again to set these values as explained in Update Task Details.

PATCH  planner/tasks/<task_id>/details
and the etag must be with the\" as

  "previewType": "checklist",
  "description": "my task desc",
  "checklist": {
      "@odata.type": "microsoft.graph.plannerChecklistItem",
      "title": "thing 1 todo",
      "isChecked": false
      "@odata.type": "microsoft.graph.plannerChecklistItem",
      "title": "thing 2 todo",
      "isChecked": false,
    "a93c93c5-10a6-1234-1234-8bafa09967a7": null
P.S. - don't forget to set your app's permissions


Popular posts from this blog

c# Service Play Sound with NAudio example by Moshe

Asp.Net Ending Response options, Response.End() vs CompleteRequest()

JS/JQ simulate Enter event