C# Google.GoogleApiException:';Google.API.Requests.RequestError尝试清除日历时无效值[400]
当我尝试按id清除特定日历时,会出现以下错误:C# Google.GoogleApiException:';Google.API.Requests.RequestError尝试清除日历时无效值[400],c#,google-api,google-calendar-api,google-api-dotnet-client,C#,Google Api,Google Calendar Api,Google Api Dotnet Client,当我尝试按id清除特定日历时,会出现以下错误: Google.GoogleApiException: 'Google.Apis.Requests.RequestError Invalid Value [400] Errors [ Message[Invalid Value] Location[ - ] Reason[invalid] Domain[global] ] ' 我的代码: var service = new CalendarService(new BaseClientServ
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设置为主日历,我可以清除主日历,但这不是我要清除的日历。方法日历:清除仅适用于主日历
见:
清除主日历。此操作删除与帐户主日历关联的所有事件
如果您创建的测试日历不是您的priamry日历(即@group.calendar.google.com
日历),并尝试清除它,您将收到
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "Invalid Value"
}
],
"code": 400,
"message": "Invalid Value"
}
}
解决方法
出于测试目的,创建测试用户并在测试用户的主日历上测试日历:清除。方法日历:清除仅适用于主日历
见:
清除主日历。此操作删除与帐户主日历关联的所有事件
如果您创建的测试日历不是您的priamry日历(即@group.calendar.google.com
日历),并尝试清除它,您将收到
{
"error": {
"errors": [
{
"domain": "global",
"reason": "invalid",
"message": "Invalid Value"
}
],
"code": 400,
"message": "Invalid Value"
}
}
解决方法
出于测试目的,创建一个测试用户并测试日历:在测试用户的主日历上清除。您是该日历的所有者吗?是的,我是为此专门制作的。您是该日历的所有者吗?是的,我是为此专门制作的。