简体   繁体   English

如何创建带有说明的计划任务?

[英]How can I create a planner task with a description?

I'm using the Microsoft Graph API with the .Net SDK. 我正在将Microsoft Graph API与.Net SDK一起使用。

I'm trying to create a new PlannerTask, and provide a description with it when doing that. 我正在尝试创建一个新的PlannerTask,并在执行此操作时提供描述。

The description for a PlannerTask is on a related object, PlannerTaskDetails, and so that object is "read-only". PlannerTask的描述位于相关对象PlannerTaskDetails上,因此该对象为“只读”。

This seems to imply that to create a PlannerTask with a Description I have to make at least two calls. 这似乎意味着要创建一个带有Description的PlannerTask,我必须至少进行两次调用。 The first call creates the PlannerTask, and the second call updates the PlannerTaskDetails. 第一个调用创建PlannerTask,第二个调用更新PlannerTaskDetails。

To update the PlannerTaskDetails, an e-tag is needed. 要更新PlannerTaskDetails,需要一个电子标签。 So I used Expand to request that the Details property is populated when returning the created PlannerTask. 因此,我使用了Expand来要求在返回创建的PlannerTask时填充Details属性。 But it is returned unpopulated (ie null). 但是它不填充就返回(即null)。

var task = await graphServiceClient
    .Planner
    .Tasks
    .Request()
    .Expand("Details")
    .AddAsync(plannerTask);

var taskPlannerDetailsETag = task.Details.GetEtag();

var taskDetails = await graphServiceClient
    .Planner
    .Tasks[task.Id]
    .Details
    .Request()
    .Header("If-Match", taskPlannerDetailsETag)
    .UpdateAsync(new PlannerTaskDetails()
    {
        Description = officeTask.Body
    });

So the next thing to try would be creating the PlannerTask, then making a second call to retrieve the PlannerTaskDetails, and then a third call to update the PlannerTaskDetails. 因此,接下来要尝试的是创建PlannerTask,然后进行第二次调用以检索PlannerTaskDetails,然后进行第三次调用以更新PlannerTaskDetails。 But I think I must be approaching this wrong, 3 network round trips to create a single task with a description seems, well, absurd. 但是我想我一定要走错了,创建一个带有描述的单个任务的3次网络往返似乎很荒谬。

What am I doing wrong? 我究竟做错了什么?

Creating a task, reading the details, then updating the details is currently the correct way of accomplishing this scenario. 当前,创建任务,阅读详细信息然后更新详细信息是完成此方案的正确方法。 Note that reading the details immediately after creating the task may fail, as the processing is asynchronous, so you should add some retry logic to have stable behavior. 需要注意的是在创建任务后立即读取的细节可能会失败,因为处理是异步的,所以你应该添加一些重试逻辑有稳定的表现。 We're working on improvements on this scenario to simplify the process. 我们正在针对这种情况进行改进,以简化流程。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM