【问题标题】:Add conference to event Google Calendar API将会议添加到活动 Google Calendar API
【发布时间】:2021-05-22 11:16:27
【问题描述】:

我可以创建活动,但我无法通过会议创建活动。

我尝试了所有这些类型:“eventHangout”“eventNamedHangout”“hangoutsMeet”,但仍然得到会议类型值无效

Google.GoogleApiException: 'Google.Apis.Requests.RequestError
Invalid conference type value. [400]
Errors [
  Message[Invalid conference type value.] Location[ - ] Reason[invalid] Domain[global]
]

这是创建和执行事件的代码:

CalendarService service = GetCalendarService();

EventDateTime start = new EventDateTime();
start.DateTime = new DateTime(2021, 02, 19, 18, 47, 0);

EventDateTime end = new EventDateTime();
end.DateTime = new DateTime(2021, 02, 19, 18, 50, 0);

Event newEvent = new Event();
newEvent.Start = start;
newEvent.End = end;
newEvent.Summary = "New event";
newEvent.Description = "description";

newEvent.ConferenceData = CreateConferenceData();

EventsResource.InsertRequest request = service.Events.Insert(newEvent, calendarId);
request.ConferenceDataVersion = 1;
Event createdEvent = request.Execute();

这里是 CreateConferenceData() 方法的代码:

 ConferenceData conferenceData = new ConferenceData()
 {
     CreateRequest = new CreateConferenceRequest()
     {
          RequestId = Guid.NewGuid().ToString(),
          ConferenceSolutionKey = new ConferenceSolutionKey()
          {
             Type = "hangoutsMeet" // Change according to your preferences
          };
     }
 };

 return conferenceData;

【问题讨论】:

  • 我怀疑问题在于您指定了CreateRequest ConferenceSolution。文档说“需要会议解决方案和至少一个入口点,或者需要 createRequest。”我会尝试只指定 ConferenceSolution+EntryPoints,或者只指定 CreateRequest。
  • @JonSkeet 谢谢你的回答。我刚刚尝试只使用 CreateRequest 并得到了 BadRequest 而没有消息,我认为我的方法是正确的
  • 那么我会尝试just ConferenceSolution+EntryPoint。文档似乎确实不鼓励您指定所有三个。
  • @JonSkeet CreateRequest 和 ConferenceSolution+EntryPoints 均无效。再次回到同一个例外:(但无论如何谢谢
  • 好的。您可能想尝试使用 API Explorer 进行试验。如果这是客户端库问题,我会感到非常惊讶,但我想这只是可能。您可能想通过developers.google.com/calendar/support 中链接的错误跟踪器提交问题 - 如果没有别的,更清晰的错误消息显然会有所帮助。

标签: c# asp.net google-calendar-api google-api-dotnet-client


【解决方案1】:

这是我的服务,完美的会议活动

            _calenarService = new CalendarService(new BaseClientService.Initializer()
            {
                HttpClientInitializer = GenerateCredentials(),
                ApplicationName = this._applicationName
            });


        var myEvent = new Event
        {
            Summary = "Google Calendar API Testing ",
            Location = "Islamabad, Punjab, Pakistan",
            Start = new EventDateTime()
            {
                DateTime = new DateTime(2021, 4, 5, 14, 0, 0),
                TimeZone = "Asia/Karachi"
            },
            End = new EventDateTime()
            {
                DateTime = new DateTime(2021, 9, 10, 15, 0, 0),
                TimeZone = "Asia/Karachi"
            },


            Recurrence = new String[] { "RRULE:FREQ=WEEKLY;BYDAY=MO" },
            //If you want to add attendee
            //Attendees = new List<EventAttendee>()
            //{
            //    new EventAttendee { Email = "......com" },
            //    new EventAttendee { Email = "......." }
            //},

           ConferenceData = new ConferenceData
            {
                ConferenceSolution = new ConferenceSolution
                {
                    Key = new ConferenceSolutionKey
                    {
                        Type = "hangoutsMeet"
                    }
                },

               CreateRequest = new CreateConferenceRequest
               {
                   RequestId = "qwerfsdiob",
                   ConferenceSolutionKey = new ConferenceSolutionKey
                   {
                       Type = "hangoutsMeet"
                   },

                  
               },

               EntryPoints = new List<EntryPoint> ()
                {
                    
                     new EntryPoint { EntryPointType = "video"  },
                  

                }
               
            }

            
        };

        var recurringEvent = _calenarService.Events.Insert(myEvent, "primary");
        recurringEvent.SendNotifications = true;
        recurringEvent.ConferenceDataVersion = 1;
        
        Event eventData = recurringEvent.Execute();

【讨论】:

  • 使用像你这样的ConferenceData 肯定仍然会给我“无效的会议数据”
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-10-09
  • 1970-01-01
  • 1970-01-01
  • 2023-04-01
  • 1970-01-01
  • 1970-01-01
  • 2012-01-26
相关资源
最近更新 更多