Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
13,483 questions
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
I'm unable to create checklist items using the graph API. I keep getting the error:
Exception of type 'Microsoft.Graph.Models.ODataErrors.ODataError' was thrown.
public async static Task<PlannerTaskDetails> UpdateDetailsOfTaskAddChecklist(GraphServiceClient graphClient, PlannerTask plannerTask, string[] checklistItems)
{
PlannerTaskDetails requestBody = await graphClient.Planner.Tasks[plannerTask.Id].Details.GetAsync();
string eTag = requestBody.AdditionalData["@odata.etag"].ToString();
requestBody.PreviewType = PlannerPreviewType.Checklist;
if (requestBody.Checklist == null)
{
requestBody.Checklist = new PlannerChecklistItems();
requestBody.Checklist.AdditionalData = new Dictionary<string, object>();
}
foreach (var i in checklistItems)
{
requestBody.Checklist.AdditionalData.Add(Guid.NewGuid().ToString(),
new
{
OdataType = "microsoft.graph.plannerChecklistItem",
Title = i,
IsChecked = false
}
);
}
var result = await graphClient.Planner.Tasks[plannerTask.Id].Details.PatchAsync(requestBody, (requestConfiguration) =>
{
requestConfiguration.Headers.Add("Prefer", "return=representation");
requestConfiguration.Headers.Add("If-Match", eTag);
});
return result;
}