静默更新PlannerTaskDetails失败 [英] Updating PlannerTaskDetails silently fails
问题描述
我正在使用Microsoft Graph .Net SDK与Planner进行交互.
我刚刚创建了PlannerTask
,我想设置Description属性.
I'm using the Microsoft Graph .Net SDK to interact with Planner.
I've just created a PlannerTask
, and I'd like to set the Description property.
我的方法包括在:如何我可以创建带有说明的计划任务吗?
以下是获取返回的PlannerTaskDetails
对象,修改描述然后更新的代码:
Here's the code which takes the returned PlannerTaskDetails
object, modifies the Description, and then updates it:
var taskDetails = taskDetailsResult.Result; // Get Previous Task Details
taskDetails.Description = description;
task.Details = await graphServiceClient
.Planner
.Tasks[task.Id]
.Details
.Request()
.Header("If-Match", taskDetails.GetEtag())
.UpdateAsync(taskDetails);
UpdateAsync返回,但返回null. 也不例外,null显然不包含任何更多信息,并且Description不变.
UpdateAsync returns, but it returns a null. There's no exception, the null obviously contains no further information, and the Description is not changed.
我使用Fiddler监视来回的HTTP通信.我可以看到PATCH
请求正在发送到Graph API,并且它设置了If-Match
标头.
I used Fiddler to monitor the HTTP traffic going back and forth. I can see that a PATCH
request is being sent to the Graph API, and it has the If-Match
header set.
奇怪的是,请求主体中的JSON对象具有两次列出的description属性!第一次使用我的值,第二次使用null.
Oddly, the JSON object in the request body has the description property listed twice! The first time with my value, and the second time with a null.
我认为反序列化器将使用它看到的某个属性的最后一个值,因此这就是为什么它不会更新.
I assume the deserializer is taking the last value it sees for a property, and so that's why it doesn't update.
我在做什么错了?
推荐答案
您正确地将代码更改为使用补丁程序对象,而不是重用现有的PlannerTaskDetail
.要取回更新的对象(如果支持),则需要设置preferred标头.
You correctly changed your code to use a patch object instead of reusing the existing PlannerTaskDetail
. To get back the updated object (if this is supported), you'll need to set the prefer header.
http://docs.oasis-open.org/odata/odata/v4.0/errata03/os/complete/part1-protocol/odata-v4.0-errata03-os-part1-protocol-complete.html#_Toc453752234, section 8.2.8.7
.Header("prefer", "return=representation")
这篇关于静默更新PlannerTaskDetails失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!