如何创建带有说明的计划任务? [英] How can I create a planner task with a description?

查看:55
本文介绍了如何创建带有说明的计划任务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在将Microsoft Graph API与.Net SDK一起使用.

I'm using the Microsoft Graph API with the .Net SDK.

我正在尝试创建一个新的PlannerTask,并在执行该操作时提供描述.

I'm trying to create a new PlannerTask, and provide a description with it when doing that.

PlannerTask的描述在一个相关的对象PlannerTaskDetails上,因此该对象是只读的".

The description for a PlannerTask is on a related object, PlannerTaskDetails, and so that object is "read-only".

这似乎意味着要创建一个带有Description的PlannerTask,我必须至少进行两次调用.第一个调用创建PlannerTask,第二个调用更新PlannerTaskDetails.

This seems to imply that to create a PlannerTask with a Description I have to make at least two calls. The first call creates the PlannerTask, and the second call updates the PlannerTaskDetails.

要更新PlannerTaskDetails,需要一个电子标签.因此,在返回创建的PlannerTask时,我使用Expand要求填充Details属性.但这是未填充的返回值(即null).

To update the PlannerTaskDetails, an e-tag is needed. So I used Expand to request that the Details property is populated when returning the created PlannerTask. But it is returned unpopulated (i.e. 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
    });

因此,接下来要尝试的是创建PlannerTask,然后进行第二次调用以检索PlannerTaskDetails,然后进行第三次调用以更新PlannerTaskDetails.但是我认为我一定要走错了,创建一个带有描述的单个任务的3次网络往返似乎很荒谬.

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. But I think I must be approaching this wrong, 3 network round trips to create a single task with a description seems, well, absurd.

我在做什么错了?

推荐答案

当前,完成此方案的正确方法是创建任务,阅读详细信息,然后更新详细信息.请注意,由于处理是异步的,因此在创建任务后立即读取详细信息可能会失败,因此应添加一些重试逻辑以使行为稳定.我们正在针对这种情况进行改进,以简化流程.

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.

这篇关于如何创建带有说明的计划任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆