将会议添加到事件Google Calendar API



我可以创建一个事件,但是我不能创建一个会议事件。

我试了所有这些类型:"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;

这是我的服务和工作完美的会议活动

_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();

这是Apps Script中的代码示例,但所需的请求主体是相同的:

function createBooking() {
const calendarId = ID_CALENDAR;
const request = {
summary: "Meet title",
description: "",
start: {
timeZone: 'America/Sao_Paulo',
dateTime: '2023-08-25T09:00:00-03:00'
},
end: {
timeZone: 'America/Sao_Paulo',
dateTime: '2023-08-25T10:30:00-03:00'
},
conferenceData: {
createRequest: {
requestId: Utilities.getUuid(),
conferenceSolutionKey: {
type: "hangoutsMeet"
},
}
},
}
const event = CalendarApi.Events.insert(request, calendarId, {conferenceDataVersion: 1});
console.log(event);
}

最新更新