如何使用GoogleCalendarAPI只删除第一次出现的重复事件

2024-05-17 18:19:12 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在使用googleapiv3的Google日历。我可以添加一个重复事件到谷歌日历,但当试图删除第一次出现的系列,整个系列被删除。在

我使用Python和authomatic_inst库,并按如下方式传递事件标识: baseID_yyyymmddThhmmssZ

delete请求就好像我只传递了baseID,但我已经检查了整个ID(带有日期和时间的ID)是否已传递。在

我使用了这个引用(https://developers.google.com/google-apps/calendar/v3/reference/events)来检索该系列的实例,并确保第一个事件的id是正确的,但是尽管从中删除了它,还是试试吧!这个工具有用,但在Python中它对我不起作用。在

def delete_gcal_event(google_event_id):
# google_event_id in the form baseID_yyyymmddThhmmssZ
# Deserialize the user's API credentials from the session storage
credentials = authomatic_inst.credentials(session['google_credentials'])

if not credentials.valid:
    credentials.refresh()
    session['google_credentials'] = credentials.serialize()

response = authomatic_inst.access(
                credentials,
                api_url('calendars/{}/events/{}', 'primary', google_event_id),
                method='DELETE',
                headers=JSON_HEADERS)

if (response.status == 204):
    return dict(success = True,
                message = "Event deleted successfully",
                status = response.status)
else:
    return dict(success = False,
                message = "Error when deleting event from google",
                status = response.status)

以前有人遇到过这个问题吗?在

非常感谢, 哈维尔


Tags: theeventidresponsesessionstatusgoogle事件