【问题标题】:not able to add meet link to google calendar events in java无法在 Java 中将会议链接添加到谷歌日历事件
【发布时间】:2021-07-28 06:11:09
【问题描述】:

我正在开发一个 spring boot api,它可以为我安排事件,但它工作正常,但随着事件,我也想添加一个 meet 链接,但我无法做到这一点。我正在使用来自云的服务帐户控制台并与此服务帐户共享我的个人帐户。如何实现 google meet?

这是我的代码:

Event event = new Event()
                    .setSummary("Google I/O 2015")
                    .setLocation("800 Howard St., San Francisco, CA 94103")
                    .setDescription("A chance to hear more about Google's developer products.");
            ConferenceSolutionKey conferenceSKey = new ConferenceSolutionKey();
            conferenceSKey.setType("hangoutsMeet");
            CreateConferenceRequest createConferenceReq = new CreateConferenceRequest();
            createConferenceReq.setRequestId("adojajaod"); // ID generated by you

            createConferenceReq.setConferenceSolutionKey(conferenceSKey);
            ConferenceData conferenceData = new ConferenceData();
            conferenceData.setCreateRequest(createConferenceReq);

            System.out.println(conferenceData);
            event.setConferenceData(conferenceData);


            DateTime startDateTime = new DateTime("2021-08-14T09:00:00-07:00");
            EventDateTime start = new EventDateTime()
                    .setDateTime(startDateTime)
                    .setTimeZone("America/Los_Angeles");
            event.setStart(start);

            DateTime endDateTime = new DateTime("2021-08-15T17:00:00-07:00");
            EventDateTime end = new EventDateTime()
                    .setDateTime(endDateTime)
                    .setTimeZone("America/Los_Angeles");
            event.setEnd(end);

            String[] recurrence = new String[]{"RRULE:FREQ=DAILY;COUNT=2"};
            event.setRecurrence(Arrays.asList(recurrence));

            EventReminder[] reminderOverrides = new EventReminder[]{
                    new EventReminder().setMethod("email").setMinutes(24 * 60),
                    new EventReminder().setMethod("popup").setMinutes(10),
            };
            Event.Reminders reminders = new Event.Reminders()
                    .setUseDefault(false)
                    .setOverrides(Arrays.asList(reminderOverrides));
            event.setReminders(reminders);

            
            event = client.events().insert("himanshuranjan30@gmail.com", event).setConferenceDataVersion(1).execute();
            System.out.printf("Event created: %s\n", event.getHtmlLink());

我在这里尝试使用会议设置会议链接,但它不起作用并给出如下错误:

{
  "code" : 400,
  "errors" : [ {
    "domain" : "global",
    "message" : "Invalid conference type value.",
    "reason" : "invalid"
  } ],
  "message" : "Invalid conference type value."
}

任何帮助将不胜感激。

【问题讨论】:

  • 我无法重现此行为。我可以使用您完全相同的代码(只需更改 calendarId)成功创建事件。您是否尝试过直接在 UI 中创建事件?是否成功创建并附加了会议?
  • 您使用的是什么 calendarId?它会创建见面链接吗?
  • 是的,我可以通过 UI 附加会议链接,但不能通过代码。您使用的是服务帐户吗? @Iamblichus
  • what calendarId you are using:“主要”。 does it create the meet link?:是的。 Are you using a service account?:不,是吗?
  • 是的,我正在创建一个服务帐户

标签: java spring-boot google-cloud-platform google-calendar-api google-meet


【解决方案1】:

conferenceSKey.setType("hangoutsMeet");

您尝试插入活动的日历似乎不接受“hangoutsMeet”电话会议类型。

验证使用日历 API 的get 来查看您的目标日历元数据。 https://developers.google.com/calendar/api/v3/reference/calendars

您可以在下面看到允许的类型,

"conferenceProperties": {
    "allowedConferenceSolutionTypes": [
      string
    ]
  }

【讨论】:

  • 知道了:{ "kind": "calendar#calendar", "etag": "\"UGZ9E6e2y1kc_Q25kEgvdR6mX_I\"", "id": "himanshuranjan30@gmail.com", "summary": "himanshuranjan30@gmail.com", "timeZone": "Asia/Kolkata", "conferenceProperties": { "allowedConferenceSolutionTypes": [ "hangoutsMeet" ] } }
猜你喜欢
  • 2017-11-16
  • 1970-01-01
  • 2014-01-19
  • 1970-01-01
  • 2017-05-29
  • 1970-01-01
  • 1970-01-01
  • 2018-03-12
  • 1970-01-01
相关资源
最近更新 更多