如何使用Google日历API在C#中的Google Meet中创建视频会议活动



嗯。。我正在尝试使用此代码创建一个事件

CalendarService service;
GoogleCredential credential;
try
{
string[] scopes = new string[] { CalendarService.Scope.Calendar };
using (var stream = new FileStream(@"C:Pruebameet.json", FileMode.Open, FileAccess.Read))
{
credential = GoogleCredential.FromStream(stream)
.CreateScoped(scopes);
}
service = new CalendarService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential
});

Event calendarEvent = new Event();
DateTime start = DateTime.Now;
calendarEvent.Kind = "";
calendarEvent.Summary = "prueba";
calendarEvent.Status = "confirmed";
calendarEvent.Visibility = "public";
calendarEvent.Description = "prueba";
calendarEvent.Creator = new Event.CreatorData
{
Email = "email@example.com", //email@example.com
Self = true
};
calendarEvent.Organizer = new Event.OrganizerData
{
Email = "email@example.com",
Self = true
};
calendarEvent.Start = new EventDateTime
{
DateTime = start,
TimeZone = "America/Mexico_City"
};
calendarEvent.End = new EventDateTime
{
DateTime = start.AddHours(1),
TimeZone = "America/Mexico_City"
};
calendarEvent.Recurrence = new String[] { "RRULE:FREQ=DAILY;COUNT=1" };
calendarEvent.Sequence = 0;
calendarEvent.HangoutLink = "";
calendarEvent.ConferenceData = new ConferenceData
{
CreateRequest = new CreateConferenceRequest
{
RequestId = "1234abcdef",
ConferenceSolutionKey = new ConferenceSolutionKey
{
Type = "hangoutsMeet"
},
Status = new ConferenceRequestStatus
{
StatusCode = "success"
}
},
EntryPoints = new List<EntryPoint>
{
new EntryPoint
{
EntryPointType = "video",
Uri = "",
Label = ""
}
},
ConferenceSolution = new ConferenceSolution
{
Key = new ConferenceSolutionKey
{
Type = "hangoutsMeet"
},
Name = "Google Meet",
IconUri = ""
},
ConferenceId = ""
};
//calendarEvent.EventType = "default";

EventsResource.InsertRequest request = service.Events.Insert(calendarEvent, "email@example.com");
request.ConferenceDataVersion = 0;
Event createEvent = request.Execute();
string url = createEvent.HangoutLink;
}
catch (Exception ex)
{
}

源代码在这里

当我执行第116行时:Event createEvent=request。执行()我得到这个错误:Google.Apis.Requests.RequestError无效的会议类型值。[400]错误[Message[会议类型值无效。]位置[-]原因[无效]域[全局]

我不知道这个错误是什么意思有人能帮我举个例子,用Google API日历中的C#类创建一个事件吗?

如createRequest:的C#库文档中所述

需要conferenceSolution和至少一个入口点createRequest。

这意味着您应该只使用CreateConferenceRequest,因为此会议是全新的(如果它已经存在,则您希望将ConferenceSolution与EntryPoints一起使用)。因此,只需删除ConferenceSolutionEntryPoints,只保留文档中指定的用于生成新会议CreateConferenceRequest,并将其附加到事件。

相关内容

  • 没有找到相关文章

最新更新