Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Client bug]: Planner CheckList .Net SDK error #2050

Closed
guilhermemgoncalves opened this issue Aug 1, 2023 · 7 comments
Closed

[Client bug]: Planner CheckList .Net SDK error #2050

guilhermemgoncalves opened this issue Aug 1, 2023 · 7 comments
Labels

Comments

@guilhermemgoncalves
Copy link

Describe the bug

I used the example on the learn site to create my request:

https://learn.microsoft.com/pt-br/graph/api/plannertaskdetails-update?view=graph-rest-1.0&tabs=csharp

I always receive the following error:

"The request is invalid:\r\nValue cannot be null.\r\nParameter name: qualifiedName"

I have tried to search for these issues and the closest thing I could find was addressed in this issue:

https://learn.microsoft.com/en-us/answers/questions/1192857/planner-task-assigned-to-user-using-graph-api

In the above case, the parameter has a corresponding class. But the checklist does not.

To Reproduce
Generate Graph Client and acquire token

public async Task<PlannerTask> InsertTarefa(string bucketId, string idPlanner, Dictionary<string, string> conteudoTask)
        {

            GraphServiceClient graphClient = CriarGraphClient(await gah.ObterTokenGraphAsync());

            var requestBody = new PlannerTask
            {
                PlanId = idPlanner,
                BucketId = bucketId,
                Title = conteudoTask["titulo"], 
                DueDateTime = DateTime.Parse(conteudoTask["dataFim"]),
                StartDateTime = DateTime.UtcNow,
                Details = new PlannerTaskDetails
                {
                    Description = conteudoTask["descricao"],
                    
                    Checklist = new PlannerChecklistItems()
                    {
                        AdditionalData = new Dictionary<string, object>
                        {
                            {
                                "95e27074-6c4a-447a-aa24-9d718a0b86fa", new
                                {
                                    OdataType = "microsoft.graph.plannerChecklistItem",
                                    Title = "Update task details",
                                    IsChecked = true
                                }
                            }
                        }
                    }
                }
            };
            try
            {
                return await graphClient.Planner.Tasks.PostAsync(requestBody);
            }
            catch (ODataError error)
            {
                Console.WriteLine(error.Error.Message);
                throw new Exception(error.Error.Message);
            }

        }

Expected behavior
Create a Task White PreBuilt Values of Checklist

Client version
SDK graphClient 5.19.0
Permissions AAD: Task.ReadAll and Task.ReadWriteAll.

Desktop (please complete the following information):
Windows 10

@andrueastman
Copy link
Member

We will fix the missing PlannerChecklistItem model so that the snippet can be

        var requestBody = new PlannerTask
        {
            PlanId = "idPlanner",
            BucketId = "bucketId",
            Title = "titulo",
            DueDateTime = DateTime.Parse("dataFim"),
            StartDateTime = DateTime.UtcNow,
            Details = new PlannerTaskDetails
            {
                Description = "descricao",

                Checklist = new PlannerChecklistItems()
                {
                    AdditionalData = new Dictionary<string, object>
                        {
                            {
                                "95e27074-6c4a-447a-aa24-9d718a0b86fa", new PlannerChecklistItem
                                    Title = "Update task details",
                                    IsChecked = true
                                }
                            }
                        }
                }
            }
        };

@ghost
Copy link

ghost commented Aug 18, 2023

I have the same issue with the Microsoft.Graph.Models.PlannerTask object. Sending this to the Create Planner Task Endpoint gives me "The request is invalid:\r\nValue cannot be null.\r\nParameter name: qualifiedName". When commenting out the "Assignments" Dictionary, it works.

            var task = new PlannerTask
            {
                PlanId = planId,
                BucketId = bucketId,
                Title = title,
                StartDateTime = DateTime.Now,
                DueDateTime = DateTime.Now.AddHours(1),
                Assignments = new PlannerAssignments
                {
                    AdditionalData = new Dictionary<string, object>
                    {
                        {
                            "95e27074-6c4a-447a-aa24-9d718a0b86fa", new
                            {
                                OdataType = "#microsoft.graph.plannerAssignment",
                                OrderHint = " !",
                            }
                        },
                    }
                }
            };

@ghost
Copy link

ghost commented Aug 18, 2023

Same with Microsoft.Graph.Models.PlannerExternalReferences and Microsoft.Graph.Models.PlannerChecklistItems in Update plannertaskdetails.

The Microsoft.Graph.Models.PlannerExternalReferences gives a different error message: "The request is invalid:\r\nAn unexpected instance annotation name 'https%3A//developer%2Emicrosoft%2Ecom/en-us/graph/graph-explorer' was found when reading from the JSON reader, In OData, Instance annotation name must start with @."

@Gopher2000
Copy link

I'm having the same issue. Is the key on the dictionary simply a unique string?

`public async static Task 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;
}`

@andrueastman
Copy link
Member

I have the same issue with the Microsoft.Graph.Models.PlannerTask object. Sending this to the Create Planner Task Endpoint gives me "The request is invalid:\r\nValue cannot be null.\r\nParameter name: qualifiedName". When commenting out the "Assignments" Dictionary, it works.

            var task = new PlannerTask
            {
                PlanId = planId,
                BucketId = bucketId,
                Title = title,
                StartDateTime = DateTime.Now,
                DueDateTime = DateTime.Now.AddHours(1),
                Assignments = new PlannerAssignments
                {
                    AdditionalData = new Dictionary<string, object>
                    {
                        {
                            "95e27074-6c4a-447a-aa24-9d718a0b86fa", new
                            {
                                OdataType = "#microsoft.graph.plannerAssignment",
                                OrderHint = " !",
                            }
                        },
                    }
                }
            };

Any chance this works out if you specify the type in the dictionary as

"95e27074-6c4a-447a-aa24-9d718a0b86fa", new PlannerAssignment
{
    OdataType = "#microsoft.graph.plannerAssignment",
    OrderHint = " !",
}

@ghost
Copy link

ghost commented Aug 23, 2023

I have the same issue with the Microsoft.Graph.Models.PlannerTask object. Sending this to the Create Planner Task Endpoint gives me "The request is invalid:\r\nValue cannot be null.\r\nParameter name: qualifiedName". When commenting out the "Assignments" Dictionary, it works.

            var task = new PlannerTask
            {
                PlanId = planId,
                BucketId = bucketId,
                Title = title,
                StartDateTime = DateTime.Now,
                DueDateTime = DateTime.Now.AddHours(1),
                Assignments = new PlannerAssignments
                {
                    AdditionalData = new Dictionary<string, object>
                    {
                        {
                            "95e27074-6c4a-447a-aa24-9d718a0b86fa", new
                            {
                                OdataType = "#microsoft.graph.plannerAssignment",
                                OrderHint = " !",
                            }
                        },
                    }
                }
            };

Any chance this works out if you specify the type in the dictionary as

"95e27074-6c4a-447a-aa24-9d718a0b86fa", new PlannerAssignment
{
    OdataType = "#microsoft.graph.plannerAssignment",
    OrderHint = " !",
}

This worked indeed. Thank you!

Is there a similar way to solve this for the PlannerExternalReferences List?
I could not find an object named Microsoft.Graph.Models.PlannerExternalReference to solve this? I am using the Package Microsoft.Identity.Web.GraphServiceClient 2.13.1, which uses Microsoft.Graph 5.12.0 internally. I don't think I can update the Microsoft.Graph package independently from Microsoft.Identity.Web.GraphServiceClient.

var details = new PlannerTaskDetails
{
    Id = taskId,
    Description = description,
    References = new PlannerExternalReferences
    {
        AdditionalData = {
			"https://learn.microsoft.com/", new
			{
				OdataType = "#microsoft.graph.plannerExternalReference",
                Alias = "Microsoft Learn",
                Type = "Other",
			}
		},
    }
};

@andrueastman
Copy link
Member

This will be resolved with #2095

I have the same issue with the Microsoft.Graph.Models.PlannerTask object. Sending this to the Create Planner Task Endpoint gives me "The request is invalid:\r\nValue cannot be null.\r\nParameter name: qualifiedName". When commenting out the "Assignments" Dictionary, it works.

            var task = new PlannerTask
            {
                PlanId = planId,
                BucketId = bucketId,
                Title = title,
                StartDateTime = DateTime.Now,
                DueDateTime = DateTime.Now.AddHours(1),
                Assignments = new PlannerAssignments
                {
                    AdditionalData = new Dictionary<string, object>
                    {
                        {
                            "95e27074-6c4a-447a-aa24-9d718a0b86fa", new
                            {
                                OdataType = "#microsoft.graph.plannerAssignment",
                                OrderHint = " !",
                            }
                        },
                    }
                }
            };

Any chance this works out if you specify the type in the dictionary as

"95e27074-6c4a-447a-aa24-9d718a0b86fa", new PlannerAssignment
{
    OdataType = "#microsoft.graph.plannerAssignment",
    OrderHint = " !",
}

This worked indeed. Thank you!

Is there a similar way to solve this for the PlannerExternalReferences List? I could not find an object named Microsoft.Graph.Models.PlannerExternalReference to solve this? I am using the Package Microsoft.Identity.Web.GraphServiceClient 2.13.1, which uses Microsoft.Graph 5.12.0 internally. I don't think I can update the Microsoft.Graph package independently from Microsoft.Identity.Web.GraphServiceClient.

var details = new PlannerTaskDetails
{
    Id = taskId,
    Description = description,
    References = new PlannerExternalReferences
    {
        AdditionalData = {
			"https://learn.microsoft.com/", new
			{
				OdataType = "#microsoft.graph.plannerExternalReference",
                Alias = "Microsoft Learn",
                Type = "Other",
			}
		},
    }
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants