簡體   English   中英

404在C#中訪問公共Google API日歷v3時出錯

[英]404 Error accessing Public Google API Calendar v3 in C#

嘗試訪問公共日歷時出現此錯誤:

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/

我的代碼:

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中也不起作用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM