我可以向日历添加多个事件吗? [英] Can I add multiple events to a calendar?

查看:59
本文介绍了我可以向日历添加多个事件吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想向日历添加多个事件.今天,我正在遍历一长串 Event 对象,一次向日历添加一个项目.如果有办法在一个请求中添加整个列表会很好吗?

I'd like to add multiple events to a calendar. Today I'm looping through a long list of Event objects adding one item at a time to the calendar. Would be nice if there was a way to add the entire list in one request?

foreach(var newEvent in myEventList)
{
     await graphClient.Me.Calendars[id].Events
        .Request()
        .AddAsync(newEvent);
}

推荐答案

您可以使用批处理来执行此操作.https://docs.microsoft.com/en-us/graph/json-批处理.

You can use batch to do this. https://docs.microsoft.com/en-us/graph/json-batching.

使用直接 REST 你可以使用

Using direct REST you can use

POST https://graph.microsoft.com/v1.0/$batch
Accept: application/json
Content-Type: application/json
{
  "requests": [
    {
      "id": "1",
      "method": "GET",
      "url": "/me/drive/root:/{file}:/content"
    },
    {
      "id": "2",
      "method": "GET",
      "url": "/me/planner/tasks"
    },
    {
      "id": "3",
      "method": "GET",
      "url": "/groups/{id}/events"
    },
    {
      "id": "4",
      "url": "/me",
      "method": "PATCH",
      "body": {
        "city" : "Redmond"
      },
      "headers": {
        "Content-Type": "application/json"
      }
    }
  ]
}

SDK 现在也很容易使用 BatchRequestContent 和 AddBatchRequestStep 功能支持这一点.

The SDK also supports this too now very easily using BatchRequestContent and AddBatchRequestStep capability.

我在 11 月的 Ignite 大会上在 28 分钟处演示了这一点.https://myignite.techcommunity.microsoft.com/sessions/82963?source=会话

I demonstrated this at Ignite in Nov at the 28 min mark. https://myignite.techcommunity.microsoft.com/sessions/82963?source=sessions

这篇关于我可以向日历添加多个事件吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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