首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Google Calendar API -清除所有事件

Google Calendar API -清除所有事件
EN

Stack Overflow用户
提问于 2021-11-15 11:13:48
回答 1查看 173关注 0票数 0

https://developers.google.com/resources/api-libraries/documentation/calendar/v3/python/latest/calendar_v3.calendars.html#clear

尝试它时,从Python或使用Google API Explorer的简单curl调用给出"400 Bad Request“响应:

代码语言:javascript
运行
复制
{
 "error": {
  "errors": [
   {
    "domain": "global",
    "reason": "invalid",
    "message": "Invalid Value"
   }
  ],
  "code": 400,
  "message": "Invalid Value"
 }
}

在API explorer或python API中,我只提供了我想要删除的相应(非主)日历的日历ID。

在Python中:

代码语言:javascript
运行
复制
service.calendars().clear(calendarId=<calid-found-in-calendarList().list()>).execute()

它返回:

代码语言:javascript
运行
复制
<HttpError 400 when requesting https://www.googleapis.com/calendar/v3/calendars/<calendar-id>4%40group.calendar.google.com/clear? returned "Invalid Value". Details: "[{'domain': 'global', 'reason': 'invalid', 'message': 'Invalid Value'}]">

知道我做错了什么吗?

EN

回答 1

Stack Overflow用户

发布于 2021-11-16 02:07:10

当我之前测试过Calendar API v3中的日历的clear方法时,我也遇到过与您相同的情况。当我使用primary的值时,没有发生错误。删除主日历的所有事件。但是,当我使用除主日历之外的日历ID时,同样的问题也发生了。

当我看到the official document的时候,它写着Clears a primary calendar. This operation deletes all events associated with the primary calendar of an account.。但是关于这个方法中的calendarId,它也提到了Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the "primary" keyword.

这些文件对我很有用。因此,我在Discovery API中检查了这个"clear“方法。Ref它如下所示。

代码语言:javascript
运行
复制
"clear": {
  "parameters": {
    "calendarId": {
      "location": "path",
      "required": true,
      "type": "string",
      "description": "Calendar identifier. To retrieve calendar IDs call the calendarList.list method. If you want to access the primary calendar of the currently logged in user, use the \"primary\" keyword."
    }
  },
  "scopes": [
    "https://www.googleapis.com/auth/calendar"
  ],
  "httpMethod": "POST",
  "id": "calendar.calendars.clear",
  "description": "Clears a primary calendar. This operation deletes all events associated with the primary calendar of an account.",
  "parameterOrder": [
    "calendarId"
  ],
  "path": "calendars/{calendarId}/clear"
},

从上面的文档中,我认为可以通过calendarList.list方法检索日历ID。但是,除了主日历之外,这种“清除”方法可能不能用于日历。

而且,当我看到错误消息时,如果使用###@group.calendar.google.com之类的日历ID,就会出现"message": "Invalid Value"错误。但是,当使用sample作为日历ID时,将返回"message": "Not Found"。看起来API可能会搜索日历。在这种情况下,即使使用URL编码,也会发生相同的问题。从这种情况来看,我认为这可能是一个bug。

但是,我不确定这是当前的规范还是bug。所以,我在问题跟踪器上搜索了这种情况。但是,不幸的是,我找不到同样的问题。那么,在谷歌问题跟踪器上报告这件事怎么样?Ref

参考资料:

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69973489

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档