【问题标题】:C# Can't insert event to Google Calendar using APIC# 无法使用 API 将事件插入 Google 日历
【发布时间】:2017-02-19 03:54:23
【问题描述】:

当我尝试在日历中插入新事件时,我收到错误消息:

未找到 [404] 错误[消息[未找到]位置[-]原因[未找到]域[全局]]

我发现我无法访问与主要不同的 callendar。

这是我的代码:

Event newEvent = new Event()
{
    Summary = ee[0],
    Start = new EventDateTime()
    {
        DateTime = DateTime.Parse(ee[2] + "T" + ee[3] + ":00+02:00")
    },
    End=new EventDateTime()
    {
        DateTime=DateTime.Parse(ee[4] + "T" + ee[5] + ":00+02:00")
    },
    Location=ee[2],
};
EventsResource.InsertRequest ins = service.Events.Insert(newEvent, nazwa_cal);
Event doins = ins.Execute();
Console.WriteLine("Event created: {0}", doins.HtmlLink);

cal_name 是我想在其中插入事件的日历的名称。

如果我将名称更改为"primary",它会完美运行。

我遵循了这些说明,但没有任何改变:LINK

提前谢谢你

【问题讨论】:

    标签: c# .net google-api google-calendar-api


    【解决方案1】:

    @adjuremods

    非常感谢您的回答。我跟随它并从列表字段中选择id 而不是summary。效果很好!

    【讨论】:

      【解决方案2】:

      尝试使用id 代替名称并检查这是否适用于您的情况。

      首先,使用 CalendarList: list 获取要在其中插入活动的日历的 ID

      GET https://www.googleapis.com/calendar/v3/users/me/calendarList?maxResults=5&key={YOUR_API_KEY}

      那么您现在可以使用其 ID insert to this event。

      发布https://www.googleapis.com/calendar/v3/calendars/google.comXXXXXXXXXX9778%40group.calendar.google.com/events?key={YOUR_API_KEY}

      {
          "end": {
              "dateTime": "2016-10-15T8:00:00",
              "timeZone": "Asia/Manila"
          },
          "start": {
              "dateTime": "2016-10-15T6:00:00",
              "timeZone": "Asia/Manila"
          }
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2022-10-12
        • 1970-01-01
        • 1970-01-01
        • 2015-09-05
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多