Google calendar api 在服务帐户中执行请求时未找到异常

Google calendar api 在服务帐户中执行请求时未找到异常,google-calendar-api,service-accounts,Google Calendar Api,Service Accounts,使用服务帐户检索日历事件时,我遇到以下错误 谁能告诉我我做错了什么 Google.API.Requests.RequestError未找到[404]错误[消息[未找到]位置[-]原因[未找到]域[全局]] //文件路径 字符串GoogleOAuth2CertificatePath=Server.MapPath(“GoogleStore\My Project-a725fb0190fc.p12”) 感谢您提供的任何有助于我的答案。通常在遇到404:Not found指定的资源未找到时。这可能发生在几

使用服务帐户检索日历事件时,我遇到以下错误

谁能告诉我我做错了什么

Google.API.Requests.RequestError未找到[404]错误[消息[未找到]位置[-]原因[未找到]域[全局]] //文件路径 字符串GoogleOAuth2CertificatePath=Server.MapPath(“GoogleStore\My Project-a725fb0190fc.p12”)


感谢您提供的任何有助于我的答案。

通常在遇到
404:Not found
指定的资源未找到时。这可能发生在几种情况下

  • 当请求的资源从未存在时
  • 访问用户无法访问的日历时
根据谷歌官方文档,建议的行动是实施

是一种用于网络应用程序的标准错误处理策略,在该策略中,客户端会在不断增加的时间内定期重试失败的请求。如果大量请求或繁重的网络流量导致服务器返回错误,则指数退避可能是处理这些错误的好策略。相反,它不是处理与速率限制、网络容量或响应时间无关的错误的相关策略,例如无效授权凭据或文件未找到错误

如果使用得当,指数退避可以提高带宽使用效率,减少获得成功响应所需的请求数,并最大限度地提高并发环境中请求的吞吐量

请注意,在每个请求中,应用程序都会发送到令牌。该令牌还可以将您的应用程序标识到Google

下面是一个相关的SO票证遇到
404未找到
错误:

 // @developer... e-mail address.
        string GoogleOAuth2EmailAddress = "939544675132-compute@developer.gserviceaccount.com";

 // certificate password ("notasecret").
        string GoogleOAuth2PrivateKey = "notasecret";


    X509Certificate2 certificate = new X509Certificate2(GoogleOAuth2CertificatePath, GoogleOAuth2PrivateKey, X509KeyStorageFlags.Exportable);

    ServiceAccountCredential credential = new ServiceAccountCredential(
            new ServiceAccountCredential.Initializer(GoogleOAuth2EmailAddress)
            {                   
                Scopes = new[] { CalendarService.Scope.Calendar }                   
            }.FromCertificate(certificate));

        // Create the service.
        service = new CalendarService(new BaseClientService.Initializer()
        {
            HttpClientInitializer = credential,
            ApplicationName = ApplicationName
        });

    ListRequest request = service.Events.List(calID);          
                request.ShowDeleted = false;
                request.SingleEvents = true;              
                events = request.Execute();