【问题标题】:Google Calendar API event insert always return 404 "not found" errorGoogle Calendar API 事件插入始终返回 404“未找到”错误
【发布时间】:2012-07-02 21:58:23
【问题描述】:

我从这里尝试了日历插入示例:https://developers.google.com/google-apps/calendar/v3/reference/events/insert#examples 无论我使用哪个属性,我总是收到 404“未找到”错误。任何人都可以对此有所了解吗?非常感谢!!!

POST https://www.googleapis.com/calendar/v3/calendars/test/events?sendNotifications=false&fields=start&key={YOUR_API_KEY}

Content-Type:  application/json
Authorization:  Bearer ya29.AHES6ZQaT3-Tj_bviwaY9Xi3gDspuBbCtEKtidnZkTXuWpI
X-JavaScript-User-Agent:  Google APIs Explorer

{
 "end": {
  "date": "2012-07-11"
 },
 "start": {
  "date": "2012-07-09"
 }
}

回应: 404 未找到

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "notFound",
    "message": "Not Found"
   }
  ],
  "code": 404,
  "message": "Not Found"
 }
}

【问题讨论】:

    标签: google-calendar-api


    【解决方案1】:

    我相信它告诉您找不到日历“测试”资源。您是否创建了一个名为“测试”的日历?如果您将“test”替换为“primary”(您的主日历),那么 Explorer 应该可以工作。

    【讨论】:

    • 我有同样的问题,我不能使用主日历,我需要连接到其他日历。
    • @Matt Healy:我没有参加私人活动。我在调用获取事件事件列表 API 之前对用户进行身份验证。有什么办法让我也可以参加私人活动吗?
    【解决方案2】:

    致胡安巴勃罗,关于非主历:

    如果是非主日历,您必须使用 id(以电子邮件地址的形式)作为 calendarId

    示例: 假设您有一个名为“test”的日历。你得到它的 id 像这样

    GET https://www.googleapis.com/calendar/v3/users/me/calendarList?key={YOUR_API_KEY}
    ->
    {
     "kind": "calendar#calendarList",
    ...
     "items": [
      {
    
       "kind": "calendar#calendarListEntry",
       "etag": ...,
       "id": "123example123example123xxx@group.calendar.google.com",
       "summary": "test",
       "description": "Testing calendar for development of Calendar related applications",
    ...
       }
      }
     ]
    }
    

    您的 POST 将如下所示

    POST https://www.googleapis.com/calendar/v3/calendars/123example123example123xxx@group.calendar.google.com/events?sendNotifications=false&fields=start&key={YOUR_API_KEY}
    

    【讨论】:

      【解决方案3】:

      可能有两个问题: 一种)。您的日历 ID 不正确。您可以通过以下步骤找到它-

      1. 在 Google 日历界面中,找到左侧的“我的日历”区域。
      2. 将鼠标悬停在您需要的日历上,然后点击向下箭头。
      3. 将出现一个菜单。点击“日历设置”。
      4. 在屏幕的“日历地址”部分,您将看到您的日历 ID。它通常是您的邮件 ID 或主邮件。

      b) 未经身份验证的使用可能已超过每日限制。通过检查 https://www.googleapis.com/calendar/v3/calendars/primary12/events?alt=json primary12 是您的日历名称

      【讨论】:

        【解决方案4】:

        我在 s=inserting 事件时也遇到了同样的问题,同时获得了一个特定的事件。但我有一个替代方案,只需指定 CalendarList asa = service.CalendarList.List().Execute(); 在执行您获得的代码之前。我不知道指定此代码后它运行的原因。如果您找到正确的方法,请在此处更新它,因为它会消耗更多的配额。

        【讨论】:

        • 没有任何与代码相关的内容,因为他正在访问可以来自任何 HTTP 客户端的 URL。
        • 这不是问题的答案。它应该被删除。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-03-03
        • 2013-12-04
        • 1970-01-01
        相关资源
        最近更新 更多