Forum Discussion
Unable to Map Planner Task Checklists in Microsoft Teams Planner Using Microsoft Graph API
Hi ,
thanks for your questions.
Is there an equivalent of IPlannerCheckListCollectionPage in Microsoft Graph API for Planner task checklists?
No, there is not an equivalent of IPlannerCheckListCollectionPage in Microsoft Graph API for Planner task checklists. However, you can use the following steps to efficiently retrieve and map checklists associated with Planner tasks:
- Get the plannerTaskDetails object for the task whose checklist you want to retrieve.
- Get the checklistItems property of the plannerTaskDetails object. This property is a collection of plannerChecklistItem objects.
- Iterate over the plannerChecklistItem objects and map them to your application objects.
Here is an example of how to retrieve and map Planner task checklists using the Microsoft Graph API:
import requests
# Get the plannerTaskDetails object for the task whose checklist you want to retrieve.
task_id = 'YOUR_TASK_ID'
url = f'https://graph.microsoft.com/v1.0/planner/tasks/{task_id}/details'
response = requests.get(url)
# Check the response status code.
if response.status_code != 200:
raise Exception(f'Failed to retrieve plannerTaskDetails object: {response.status_code}')
# Get the checklistItems property of the plannerTaskDetails object.
planner_task_details = response.json()
checklist_items = planner_task_details['checklistItems']
# Iterate over the plannerChecklistItem objects and map them to your application objects.
application_checklist_items = []
for checklist_item in checklist_items:
application_checklist_item = {
'id': checklist_item['id'],
'title': checklist_item['title'],
'isChecked': checklist_item['isChecked'],
}
application_checklist_items.append(application_checklist_item)
# Do something with the application_checklist_items list.
The recommended method for mapping checklists associated with Planner tasks is to use the approach described above. This approach is efficient because it only requires a single request to retrieve the plannerTaskDetails object and the checklistItems property.
Another alternative method to retrieve Planner task checklists is to use the plannerChecklistItem resource. However, this approach is less efficient because it requires a separate request for each checklist item.
You can use these links as a reference:
plannerChecklistItems-Ressourcentyp - Microsoft Graph v1.0 | Microsoft Learn
Use the Planner REST API - Microsoft Graph v1.0 | Microsoft Learn
Please click Mark as Best Response & Like if my post helped you to solve your issue.
This will help others to find the correct solution easily. It also closes the item.
If the post was useful in other ways, please consider giving it Like.
Kindest regards,
Leon Pavesic
(LinkedIn)
Hello LeonPavesic ,
I am currently working on a project where I need to create checklists in Planner tasks using the Graph API SDK in C#. I've encountered an issue while attempting to achieve this goal, and I'm seeking assistance to clarify a few points and resolve the problem.
Problem Description:
I am trying to create checklists in already created tasks using the Graph API SDK in C#. I am trying to use this graph API for 2 cases:
await graphClient.Planner.Tasks["{plannerTask-id}"].PatchAsync(requestBody, (requestConfiguration) => { requestConfiguration.Headers.Add("Prefer", "return=representation"); requestConfiguration.Headers.Add("If-Match", "W/\"JzEtVGFzayAgQEBAQEBAQEBAQEBAQEBAWCc=\""); });
I have attempted two methods:
1st Way: I tried to update the task details of an already created task with the details property set to NULL.
2nd Way: I attempted to update the name of a checklist within an already created task with checklists added to it.
In both cases, I am receiving the same exception:
HResult=0x80131500
Message=Message:
The request is invalid: Value cannot be null.
Parameter name: qualifiedName
Questions:
- Is it the correct approach to create checklists in tasks when the details property is NULL?
- Why am I getting the same exception in both cases, whether the details property is NULL or not?
- Could you please confirm if there is any way to create checklists using the Graph API in C# with the details property set to NULL? If yes, could you provide implementation details or code examples?
I appreciate any insights or guidance you can provide to help me resolve this issue. Thank you in advance for your assistance!