尝试访问公共日历时出现此错误:
An unhandled exception of type 'Google.GoogleApiException' occurred in mscorlib.dll
Google.Apis.Requests.RequestError
Not Found [404]
Errors [
Message[Not Found] Location[ - ] Reason[notFound] Domain[global]
当我使用简单的GET HTTP调用Google API时,我的API密钥和CalendarID正常工作。
我在此处使用博客文章来创建此代码:https://www.daimto.com/public-google-calendars-with-c/
mycode的:
class Program
{
static void Main(string[] args)
{
var service = new CalendarService(new BaseClientService.Initializer()
{
ApiKey = "My API Key From Google Console",
ApplicationName = "I put my API Key name from Google Console here",
});
var events = service.Events.List("thefirstacademy.org_2ldo8np1v5tr1qlpbho6ip6tog%40group.calendar.google.com").Execute();
foreach (var myEvent in events.Items)
{
Console.WriteLine(string.Format("Event: {0} Start: {1} End: {2}", myEvent.Summary, myEvent.Start.DateTime.ToString(), myEvent.End.DateTime.ToString()));
}
}
}
答案 0 :(得分:0)
我找到了答案。使用的日历ID必须在" group.calendar.google.com"之前有@符号。部分。尽管ID在GET HTTP中有效,但它在C#中的Google.API.Calendar.V3中无效。