0

I want to update the "ConversationThreadId" field in a PlannerTask.

This is my code:

plannerTask = await graphClient.Planner.Tasks["XXXXXXXXX"].Request().GetAsync();
var eTagId = plannerTask.GetEtag();
plannerTask.ConversationThreadId = "YYYYYYYY";
await graphClient.Planner.Tasks[plannerTask.Id]
    .Request()
    .Header("Prefer", "return=representation")
    .Header("If-Match", eTagId)
    .UpdateAsync(plannerTask);

And it throws this error:

Message: The request is invalid: An unexpected 'StartObject' node was found for property named 'assignedBy' when reading from the JSON reader. A 'PrimitiveValue' node was expected.

What am I doing wrong?

Thank you

Carlos
  • 1,638
  • 5
  • 21
  • 39

1 Answers1

1

The way to get it is:

plannerTask = await graphClient.Planner.Tasks["XXXXXXXXX"].Request().GetAsync();
var eTagId = plannerTask.GetEtag();
var newTask = new PlannerTask {
        ConversationThreadId = "YYYYYYYY"
};
await graphClient.Planner.Tasks[plannerTask.Id]
    .Request()
    .Header("Prefer", "return=representation")
    .Header("If-Match", eTagId)
    .UpdateAsync(newTask);

This is because it is not a PUT but a PATCH, and so we only should send the fields that have changed. I was sending the full object, and that was the problem. Now I create newTask and only specify "ConversationThreadId" in it. This way works like a charm for me.

Carlos
  • 1,638
  • 5
  • 21
  • 39
  • 1
    Yes, this is the problem. When issuing a patch, you should only send the fields you are changing. Otherwise your request tries to "set" multiple read only fields (by specifying them in the request), which is going to be rejected. In this case, the structure of the field doesn't get interpreted correctly as the assignedBy value isn't meant to be written to. The error message is misleading, I'll see if we can do anything about that. – Tarkan Sevilmis Oct 12 '21 at 17:09