Google Calendar Events insert接口不识别eventType参数问题问询
Google Calendar API 创建Focus Time事件失败的排查方案
检查权限与API授权
确认授权的scope包含https://www.googleapis.com/auth/calendar.events(可修改事件的权限),只读或受限scope会导致eventType被强制重置为default。在「Try this method」页面重新发起授权,确保弹窗中勾选了修改日历事件的权限。验证参数结构与格式
确保eventType直接嵌套在resource根对象下,手动重新输入"eventType": "focusTime",避免复制粘贴带来的不可见特殊字符。同时检查时区格式,将-00:00替换为标准UTC格式Z(如2023-02-07T13:00:00Z),部分地区日历对时区格式的兼容性更严格。排查测试页面的缓存问题
Google API测试页偶尔存在缓存异常,清空浏览器缓存或使用无痕窗口重新测试。也可以跳过测试页,用curl直接调用API验证:curl --request POST \ 'https://www.googleapis.com/calendar/v3/calendars/primary/events' \ --header 'Authorization: Bearer YOUR_ACCESS_TOKEN' \ --header 'Content-Type: application/json' \ --data '{ "end": {"dateTime": "2023-02-07T15:00:00Z"}, "start": {"dateTime": "2023-02-07T13:00:00Z"}, "eventType": "focusTime", "summary": "Focus Event Test" }'如果curl调用成功,说明问题出在测试页本身。
确认账号功能支持
Focus Time功能仅对部分Google账号开放,比如Workspace(原G Suite)账号,部分个人账号可能因地区或套餐限制无法使用该事件类型,可换一个Workspace账号测试验证。
内容的提问来源于stack exchange,提问作者Scott
相关产品推荐
相关产品推荐

