Google.GoogleApiException: 'Google.Apis.Requests.RequestError 尝试清除日历时无效值 [400]
Google.GoogleApiException: 'Google.Apis.Requests.RequestError Invalid Value [400] when trying to clear calendar
当我尝试通过 id 清除特定日历时,出现以下错误:
Google.GoogleApiException: 'Google.Apis.Requests.RequestError
Invalid Value [400]
Errors [
Message[Invalid Value] Location[ - ] Reason[invalid] Domain[global]
]
'
我的代码:
var service = new CalendarService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = ApplicationName,
});
service.Calendars.Clear("mycalendarid").Execute();
//service.Calendars.Clear("primary").Execute();
var ev = new Event();
EventDateTime start = new EventDateTime();
start.DateTime = new DateTime(2020, 8, 11, 8, 0, 0);
EventDateTime end = new EventDateTime();
end.DateTime = new DateTime(2020, 8, 11, 9, 10, 0);
ev.Start = start;
ev.End = end;
ev.Summary = "3y MA";
ev.Description = "Lektier: blablabla \nblabla bla \n \nNote:\nBla Bla";
var calendarId = "mycalendarid";
Event recurringEvent = service.Events.Insert(ev, calendarId).Execute();
Console.WriteLine("Event created: %s\n", ev.HtmlLink);
我可以将活动添加到正确的日历,但是当我尝试清除同一日历时出现错误。如果我将日历 ID 设置为主日历,我可以清除主日历,但这不是我要清除的日历。
方法Calendars: clear
仅适用于主日历
查看 documentation:
Clears a primary calendar. This operation deletes all events associated with the primary calendar of an account.
如果您创建的测试日历不是您的主日历(即 @group.calendar.google.com
日历)并尝试清除它,您将收到
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "Invalid Value"
}
],
"code": 400,
"message": "Invalid Value"
}
}
解决方法
出于测试目的,创建测试用户并在测试用户的主日历上测试 Calendars: clear
。
当我尝试通过 id 清除特定日历时,出现以下错误:
Google.GoogleApiException: 'Google.Apis.Requests.RequestError
Invalid Value [400]
Errors [
Message[Invalid Value] Location[ - ] Reason[invalid] Domain[global]
]
'
我的代码:
var service = new CalendarService(new BaseClientService.Initializer()
{
HttpClientInitializer = credential,
ApplicationName = ApplicationName,
});
service.Calendars.Clear("mycalendarid").Execute();
//service.Calendars.Clear("primary").Execute();
var ev = new Event();
EventDateTime start = new EventDateTime();
start.DateTime = new DateTime(2020, 8, 11, 8, 0, 0);
EventDateTime end = new EventDateTime();
end.DateTime = new DateTime(2020, 8, 11, 9, 10, 0);
ev.Start = start;
ev.End = end;
ev.Summary = "3y MA";
ev.Description = "Lektier: blablabla \nblabla bla \n \nNote:\nBla Bla";
var calendarId = "mycalendarid";
Event recurringEvent = service.Events.Insert(ev, calendarId).Execute();
Console.WriteLine("Event created: %s\n", ev.HtmlLink);
我可以将活动添加到正确的日历,但是当我尝试清除同一日历时出现错误。如果我将日历 ID 设置为主日历,我可以清除主日历,但这不是我要清除的日历。
方法Calendars: clear
仅适用于主日历
查看 documentation:
Clears a primary calendar. This operation deletes all events associated with the primary calendar of an account.
如果您创建的测试日历不是您的主日历(即 @group.calendar.google.com
日历)并尝试清除它,您将收到
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "Invalid Value"
}
],
"code": 400,
"message": "Invalid Value"
}
}
解决方法
出于测试目的,创建测试用户并在测试用户的主日历上测试 Calendars: clear
。