ifh
ifh

Reputation: 311

Add Planner Task with checklist

I'm trying to create a new task with a checklist in it.

I read in this article that I need to do this in two steps;
1. Create the task
2. PATCH the task, adding checklist items.

When trying to PATCH to add tasks, it doesn't add anything. It only edits existing values, like "title". I cannot find any way or documentation to PUT details, or create them on initial POST when creating the task.

Anyone know how to do this?

POST — Creating new task:

URI: https://graph.microsoft.com/v1.0/planner/tasks
Content-Type : application/json

RAW:
{
  "planId": "{plan_id}",
  "bucketId": "{bucket_id}",
  "title": "Here is a task",
  "checklist": {
    "95e27074-6c4a-447a-aa24-9d718a0b86fa":{
      "@odata.type": "microsoft.graph.plannerChecklistItem",
      "title": "Task details",
      "ischecked": true
    },
    "d280ed1a-9f6b-4f9c-a962-fb4d00dc50ff":{
      "@odata.type": "microsoft.graph.plannerChecklistItem"
    }
  }
}

Response: Body, 201 success:

BODY:
{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#planner/tasks/$entity",
    "@odata.etag": "W/\"…ETag…\"",
    "planId": "{plan_id}",
    "bucketId": "{bucket_id}",
    "title": "Here is a task",
    "orderHint": "8586523326629295130",
    "assigneePriority": "",
    "percentComplete": 0,
    "startDateTime": null,
    "createdDateTime": "2019-02-04T09:57:02.5480677Z",
    "dueDateTime": null,
    "hasDescription": false,
    "previewType": "automatic",
    "completedDateTime": null,
    "completedBy": null,
    "referenceCount": 0,
    "checklistItemCount": 0,
    "activeChecklistItemCount": 0,
    "conversationThreadId": null,
    "id": "{task_id}",
    "createdBy": {
        "user": {
            "displayName": null,
            "id": "{UID}"
        }
    },
    "appliedCategories": {},
    "assignments": {}
}

Also tried putting checklist block inside a details block, and get exact same result.

"details": {
  "checklist": { … }
}

PATCH — Updating existing task:


URI: https://graph.microsoft.com/v1.0/planner/tasks/{task_id}

HEADERS:
If-Match : W/"…ETag…"
Content-type : application/json

RAW:
{
  "title": "New title",
  "checklist": {
    "95e27074-6c4a-447a-aa24-9d718a0b86fa":{
      "@odata.type": "microsoft.graph.plannerChecklistItem",
      "title": "Update task details",
      "ischecked": true
    },
    "d280ed1a-9f6b-4f9c-a962-fb4d00dc50ff":{
      "@odata.type": "microsoft.graph.plannerChecklistItem"
    }
  }
}

Response: Empty, 204 success. Title is changed, but no new checklist items.

Upvotes: 0

Views: 1870

Answers (1)

Marc LaFleur
Marc LaFleur

Reputation: 33094

You cannot update the details at the same time you're creating the task. The plannerTask and plannerTaskDetails are distinct objects. Furthermore, the details property of a plannerTask is read-only.

You need to first create a plannerTask and then update it's associated plannerTaskDetails.

Upvotes: 1

Related Questions