谷歌日历API更新“缺少结束时间”

4
我正在尝试使用以下方法更新一个事件:
PUT https://www.googleapis.com/calendar/v3/calendars/primary/events/q4es0o2o70naq8idj1dj6q4354

{
 "reminders" {"useDefault":true},
 "summary":"updatedsummary",
 "description":"updated desc"
}

但是却得到了一个响应:

{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "required",
    "message": "Missing end time."
   }
  ],
  "code": 400,
  "message": "Missing end time."
 }
}

如果我只需要更新摘要或其他字段,为什么需要一个结束时间?
1个回答

5
PUT https://www.googleapis.com/calendar/v3/calendars/calendarId/events/eventId

如果想要使用events.update更新活动,需要填写所有字段。最好的方法是进行event.get更改所需字段,然后发送回去。

更好的选择

如果只想更新一些字段,请使用events.patch

PATCH https://www.googleapis.com/calendar/v3/calendars/calendarId/events/eventId

这个特定的答案在我的使用情况下非常有用,应该在Google日历API中进行更多的文档记录,特别是因为我和许多其他用户可能最初会参考“更新”方法来更新特定变量。就像在这种情况下一样,“Patch”方法更加有效,也许应该被称为“Update”,因为那更有意义。 - Richard Ansell
1
非常好的观点,我会看看是否能找到谷歌的人报告。 - Linda Lawton - DaImTo
1
谢谢@DalmTo - 我刚在API的特定页面上发布了反馈信息。你的回答刚刚节省了我大量的时间,因为我不用再试图找出为什么我不能只更新一些特定字段而不输入其他信息。我一直在赶着设置特定功能,从未考虑过或猜到“Patch”是一个合适的替代品!再次感谢。 - Richard Ansell

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接