Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/303.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 404在C中访问公共Google API日历v3时出错#_C#_Google Api_Http Status Code 404_Google Calendar Api - Fatal编程技术网

C# 404在C中访问公共Google API日历v3时出错#

C# 404在C中访问公共Google API日历v3时出错#,c#,google-api,http-status-code-404,google-calendar-api,C#,Google Api,Http Status Code 404,Google Calendar Api,尝试访问公共日历时,我遇到以下错误: 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调用Goog

尝试访问公共日历时,我遇到以下错误:

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调用GoogleAPI时,我的API键和CalendarID就起作用了

我使用此处的博客帖子创建了以下代码:

霉菌代码:

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()));
        }
    }
}

我找到了答案。使用的日历ID必须在“group.Calendar.google.com”部分前面有一个@符号。尽管该ID在GET HTTP中有效,但在C#中的Google.API.Calendar.V3中却不起作用