C# Google日历事件未显示在日历中
我们已经在谷歌创建了一个服务帐户,并使用日历API添加事件,它在之前运行良好,在谷歌停止该帐户并重新激活后,它就不工作了 我们尝试了新的服务帐户,并逐行调试了代码,并没有出现错误,还返回了创建的事件,但并没有显示在日历中C# Google日历事件未显示在日历中,c#,google-api,google-calendar-api,google-api-dotnet-client,service-accounts,C#,Google Api,Google Calendar Api,Google Api Dotnet Client,Service Accounts,我们已经在谷歌创建了一个服务帐户,并使用日历API添加事件,它在之前运行良好,在谷歌停止该帐户并重新激活后,它就不工作了 我们尝试了新的服务帐户,并逐行调试了代码,并没有出现错误,还返回了创建的事件,但并没有显示在日历中 CalendarService service = null; var serviceAccountCredentialFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDi
CalendarService service = null;
var serviceAccountCredentialFilePath =
Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
"ServiceAccount_Key.json");
if (Path.GetExtension(serviceAccountCredentialFilePath).ToLower()
== ".json")
{
GoogleCredential credential;
string[] scopes = new string[] {
CalendarService.Scope.Calendar, // Manage your calendars
CalendarService.Scope.CalendarReadonly // View your Calendars
};
using (var stream = new FileStream(serviceAccountCredentialFilePath, FileMode.Open, FileAccess.Read))
{
credential = GoogleCredential.FromStream(stream)
.CreateScoped(scopes);
}
// Create the service.
service = new CalendarService(new BaseClientService.Initializer
{
HttpClientInitializer = credential,
ApplicationName = "Esoco"
});
}
// End //
// Insert Event //
var myEvent = new Event
{
Id = guid,
//Transparency = "OPAQUE",
Summary = subject,
Location = location,
Start = new EventDateTime { TimeZone = timezone, DateTime = start },
End = new EventDateTime { TimeZone = timezone, DateTime = end },
Attendees = objattendees,
Organizer = organizerdata,
Description = summary,
};
myEvent.Start.DateTimeRaw = myEvent.Start.DateTimeRaw.Replace("Z", "");
myEvent.End.DateTimeRaw = myEvent.End.DateTimeRaw.Replace("Z", "");
//myEvent.ICalUID
var recurringEvent = service.Events.Insert(myEvent, "primary");
recurringEvent.SendNotifications = true;
try
{
var outputofevent = recurringEvent.Execute();
ScriptManager.RegisterClientScriptBlock(this, typeof(string), "Alertscript", "alert('"+outputofevent.Status+"')", true);
}
预期结果是在日历中插入事件显示,但实际结果不显示在日历中请记住,以下代码将您的事件插入服务帐户主日历
var recurringEvent = service.Events.Insert(myEvent, "primary");
要查看这些活动,您需要创建events.list或邀请其他人参加活动,以便他们可以在自己的日历中查看
错误问题已记录。
除此之外,目前论坛上有一个关于邀请未发送的问题过去几周,我的团队也有同样的问题, 这就是我的团队要解决的问题 我们的情景
google的服务帐户-calendar@mycompany.iam.gserviceaccount.com
我们为解决问题所做的工作
system@mycompany.com
)- 进入“日历>设置>与特定人员共享”,然后
- 添加
带有“对事件进行更改”google-calendar@mycompany.iam.gserviceaccount.com
calendar.events.insert({
日历ID:'system@mycompany.com“,//您如何知道它没有显示在日历中?您正在执行要检查的event.list吗?请检查垃圾箱(在“设置”下)。可能是活动被自动取消。我面临着同样的问题。@DaImTo是的,它返回为250,然后事件被插入。您是否扫描了events.list返回的事件,以找到您关注的事件并完成了一个事件。是否查看发送了哪些与会者?@DaImTo-是的,所有活动的与会者中都有我的名字,我也有e按事件id执行了一个事件获取方法,它返回了详细信息。我执行了events.list并将其获取为250,同时这是已创建事件的html链接:。当我打开此链接时,我无法在url中找到+请求的+事件…响应url:邀请了我的同事在与会者中的电子邮件id…他们没有收到邀请。检查过去几天谷歌日历上的问题,每个人都有没有收到邀请通知的问题。@dalmTo-日历没有被阻止供与会者使用。那么到底是什么问题?
calendar.events.insert({
calendarId: 'primary', // it will create an event into service account's calendar
resource: data,
sendNotifications: true
})
calendar.events.insert({
calendarId: 'system@mycompany.com', // << we changed from 'primary' to just-created-user
resource: data,
sendNotifications: true
})