Google calendar api 谷歌日历API事件插入始终返回404“;“未找到”;错误

Google calendar api 谷歌日历API事件插入始终返回404“;“未找到”;错误,google-calendar-api,Google Calendar Api,我在这里尝试了日历插入示例: 无论我使用哪个属性,我都会得到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.AHES

我在这里尝试了日历插入示例: 无论我使用哪个属性,我都会得到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"
 }
}

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

在获取特定事件时,s=插入事件也会遇到同样的问题。但我有另一个选择,只是具体说明一下 CalendarList asa=service.CalendarList.List().Execute();
在执行代码之前,您将获得。我不知道为什么在指定此代码后它会运行。如果您找到了正确的方法,请在此处更新,因为它将消耗更多配额计数。

对于JuanPablo,您是非主日历:

非主日历的情况下必须使用id(以电子邮件地址的形式)作为日历id

例如: 假设您有一个名为“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 https://www.googleapis.com/calendar/v3/calendars/123example123example123xxx@group.calendar.google.com/events?sendNotifications=false&fields=start&key={YOUR_API_KEY}
你的帖子会像这样

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 https://www.googleapis.com/calendar/v3/calendars/123example123example123xxx@group.calendar.google.com/events?sendNotifications=false&fields=start&key={YOUR_API_KEY}
可能有两个问题: a) 。您的日历id不正确。您可以通过以下步骤找到它-

  • 在Google日历界面中,找到左侧的“我的日历”区域
  • 将鼠标悬停在所需的日历上,然后单击向下箭头
  • 将出现一个菜单。单击“日历设置”
  • 在屏幕的“日历地址”部分,您将看到您的日历ID。它通常会显示您的邮件ID或主ID
  • b) 未经认证使用的每日限制可能已超过。通过
    primary12是您的日历名

    我也有同样的问题,我无法使用主日历,我需要连接到其他日历。@马特·希利:我没有私人事件。我在调用获取事件列表API之前对用户进行身份验证。有什么方法可以让我也获得私有事件吗?因为他点击的URL可以来自任何HTTP客户端,所以与代码无关。