![](/img/trans.png)
[英]How to create event in Google Calendar API with videoconference in Google Meet in C#?
[英]How to create event with videoconference in Google Meet in C# using Google Calendar API?
嗯..我正在嘗試這段代碼來創建一個事件
CalendarService service;
GoogleCredential credential;
try
{
string[] scopes = new string[] { CalendarService.Scope.Calendar };
using (var stream = new FileStream(@"C:\Prueba\meet.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.Execute(); 我收到此錯誤: Google.Apis.Requests.RequestError 會議類型值無效。 [400] 錯誤 [消息[無效的會議類型值。] 位置 [-] 原因 [無效] 域 [全局]
我不知道這個錯誤是什么意思,我錯了 誰能幫我舉個例子,使用來自 Google API 日歷的類 C# 創建一個事件?
如createRequest的C# 庫文檔中所述:
需要conferenceSolution 和至少一個entryPoint,或者需要createRequest。
這意味着您應該只使用CreateConferenceRequest
,因為這個會議是全新的(如果它已經存在,那么您可能希望將ConferenceSolution與EntryPoints一起使用)。 因此,只需刪除ConferenceSolution
和EntryPoints
以僅保留CreateConferenceRequest
,如文檔中指定的用於生成新會議並將其附加到事件中。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.