Google Calendar API事件插入始终返回404“未找到”错误

时间:2012-07-02 21:58:24

标签: google-calendar-api

我在这里尝试了日历插入示例: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"
 }
}

4 个答案:

答案 0 :(得分:11)

我相信它告诉你无法找到日历“测试”资源。你创建了一个名为“test”的日历吗?如果将“test”替换为“primary”(主日历),则Explorer应该可以正常工作。

答案 1 :(得分:2)

至JuanPablo,重新非主日历:

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

实施例: 假设你有一个名为'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}

答案 2 :(得分:0)

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

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

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

答案 3 :(得分:-2)

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

相关问题