首页 > 解决方案 > Google Calendar API 删除“conferenceData”嵌套对象

问题描述

编辑:这已被确定为此处的错误

我正在尝试与新的日历活动一起制作 Google Meet。但是,由于某种原因,返回的事件不包括任何会议数据,甚至没有一个状态为失败的事件。

这是我的代码。我省略了身份验证步骤,因为我没有收到身份验证错误。

def generateMeet(emails=None, fake=False):
    if emails is None:
        emails = []

    if fake:
        return "https://www.google.com", get_random_string(10)

    now = datetime.utcnow().isoformat() + 'Z'  # 'Z' indicates UTC time
    inonehour = (datetime.utcnow() + timedelta(hours=1)).isoformat() + 'Z'

    event = {
        'summary': 'Orb Meeting',
        'start': {
            'dateTime': now,
            'timeZone': 'America/New_York',
        },
        'end': {
            'dateTime': inonehour,
            'timeZone': 'America/New_York',
        },
        'sendUpdates': "none",
        'reminders': {
            'useDefault': False,
        },
        'attendees': [{'email': x} for x in emails],
        'conferenceDataVersion': 1,
        'conferenceData': {
            'createRequest': {
                'requestID': get_random_string(10),
                'conferenceSolutionKey': {
                    'type': 'hangoutsMeet'
                },

            }
        }
    }

    ret = service.events().insert(calendarId='primary', body=event).execute()
    return ret['conferenceData']['entryPoints'], ret['id']

这将返回一个关键错误,因为会议数据不存在。这是我运行返回之前的完整“ret”对象:

{'kind': 'calendar#event', 'etag': '"3197938620273000"', 'id': '5fb6epfe93sceba9scjt1nevsk', 'status': 'confirmed',
     'htmlLink': 'https://www.google.com/calendar/event?eid=NWZiNmVwZmU5M3NjZWJhOXNjanQxbmV2c2sgZm9ycmVzdG1pbG5lckBt',
     'created': '2020-09-01T14:08:30.000Z', 'updated': '2020-09-01T14:08:30.162Z', 'summary': 'Orb Meeting',
     'creator': {'email': '[my email]', 'self': True},
     'organizer': {'email': '[my email]', 'self': True},
     'start': {'dateTime': '2020-09-01T10:08:28-04:00', 'timeZone': 'America/New_York'},
     'end': {'dateTime': '2020-09-01T11:08:28-04:00', 'timeZone': 'America/New_York'},
     'iCalUID': '5fb6epfe93sceba9scjt1nevsk@google.com', 'sequence': 0,
     'attendees': [{'email': '[my other email]', 'displayName': 'Forrest Milner', 'responseStatus': 'needsAction'}],
     'reminders': {'useDefault': False}}

谁能告诉我为什么我的请求中的会议数据部分可能会被删除?我将 ConferenceDataVersion 设置为 1,并使用随机字符串。

我尝试添加虚拟“受邀者”。在这次试验中,我邀请了我的第二个 gmail 帐户,而在其他试验中,我邀请了几个域为“example.com”的虚拟帐户。这会更新与会者,但不会显示会议数据。

我也试过等待几分钟,然后列出我所有的事件。即使在等待之后,会议数据也没有填写。当我在 GUI ( https://calendar.google.com/calendar/r ) 上查看我的日历时,它也没有附加 Google Meet。

感谢您的任何帮助。

标签: pythongoogle-calendar-api

解决方案


是的,这是一个错误,如果它是高优先级,您可以使用以下内容“修补”您创建的事件:

const eventPatch = {
   conferenceData: {
   createRequest: { requestId: "yourRandomString" },
  },
};
let response = await calendar.events.patch({
  calendarId: 'primary',
  eventId: "createdEventID",
  resource: eventPatch,
  sendNotifications: true,
  conferenceDataVersion: 1,
});

参考:https ://developers.google.com/calendar/create-events#conferencing


推荐阅读