C# 403在Google Calendar Api c中插入带有助理的事件时出错#

C# 403在Google Calendar Api c中插入带有助理的事件时出错#,c#,.net,google-calendar-api,C#,.net,Google Calendar Api,在一个.net项目中,我试图使用google calendar v3 api添加一个带有一些参与者的事件。我可以成功创建没有助理的事件,但当我尝试添加助理时,会出现以下错误: Google.Apis.Requests.RequestError Calendar usage limits exceeded. [403] Errors [ Message[Calendar usage limits exceeded.] Location[ - ] Reason[quotaExceeded]

在一个.net项目中,我试图使用google calendar v3 api添加一个带有一些参与者的事件。我可以成功创建没有助理的事件,但当我尝试添加助理时,会出现以下错误:

Google.Apis.Requests.RequestError
Calendar usage limits exceeded. [403]
Errors [
    Message[Calendar usage limits exceeded.] Location[ - ] Reason[quotaExceeded] Domain[usageLimits]
]
我以前没有做过任何请求(实际上,我已经创建了新的gmail帐户,并将它们各自的日历与api凭据链接起来),并且添加了5个以上的事件

下面是创建事件的代码

public class CalendarQuickstart
{
    private string jsonFile { get; set; }
    private string RutaCredentials { get; set; }
    private string calanderId { get; set; }

    public CalendarQuickstart()
    {
        RutaCredentials = WebConfigurationManager.AppSettings["rutaCredentials"];
        jsonFile= "credentials.json";
        calanderId = "9cp270uok8t0tq2uss3qb54dos@group.calendar.google.com";
    }

    static List<Event> DB = 
         new List<Event>() {
            new Event(){
                Id = "eventid" + 3,
                Summary = "Google I/O 2015",
                Location = "800 Howard St., San Francisco, CA 94103",
                Description = "A chance to hear more about Google's developer products.",
                Start = new EventDateTime()
                {
                    DateTime = new DateTime(2019, 09, 29, 15, 30, 0),
                    TimeZone = "America/Los_Angeles",
                },
                End = new EventDateTime()
                {
                    DateTime = new DateTime(2019, 09, 30, 15, 30, 0),
                    TimeZone = "America/Los_Angeles",
                }
                ,
                  Recurrence = new String[] {
                      "RRULE:FREQ=WEEKLY;BYDAY=MO"
                  }
                 ,
                Attendees = new EventAttendee[] {

                    new EventAttendee() { Email = "gustavooguedareyes@gmail.com"}
                }
            }
         };



    public async Task crear_evento()
    {

        string[] Scopes = { CalendarService.Scope.Calendar };

        ServiceAccountCredential credential;

        string filePath = System.Web.Hosting.HostingEnvironment.MapPath(RutaCredentials + jsonFile);

        using (var stream =
            new FileStream(filePath, FileMode.Open, FileAccess.Read))
        {
            var confg = Google.Apis.Json.NewtonsoftJsonSerializer.Instance.Deserialize<JsonCredentialParameters>(stream);
            credential = new ServiceAccountCredential(
               new ServiceAccountCredential.Initializer(confg.ClientEmail)
               {
                   Scopes = Scopes
               }.FromPrivateKey(confg.PrivateKey));
        }

        var service = new CalendarService(new BaseClientService.Initializer()
        {
            HttpClientInitializer = credential,
            ApplicationName = "Calendar API Sample",
        });


        var myevent = DB.Find(x => x.Id == "eventid" + 3);

        var InsertRequest = service.Events.Insert(myevent, calanderId);

        try
        {
            InsertRequest.Execute();
        }
        catch (Exception e)
        {
            try
            {
                service.Events.Update(myevent, calanderId, myevent.Id).Execute();
                Console.WriteLine("Insert/Update new Event ");
                Console.WriteLine(e.ToString());
                Console.Read();

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.ToString());
                Console.WriteLine("can't Insert/Update new Event ");

            }
        }



    }
}
公共类日历快速启动
{
私有字符串jsonFile{get;set;}
私有字符串RutaCredentials{get;set;}
私有字符串calanderId{get;set;}
公共日历快速启动()
{
RutaCredentials=WebConfigurationManager.AppSettings[“RutaCredentials”];
jsonFile=“credentials.json”;
calanderId=”9cp270uok8t0tq2uss3qb54dos@group.calendar.google.com";
}
静态列表数据库=
新名单(){
新事件(){
Id=“eventid”+3,
Summary=“谷歌I/O 2015”,
地点=“800 Howard St.,旧金山,CA 94103”,
Description=“有机会了解更多关于谷歌开发者产品的信息。”,
开始=新的EventDateTime()
{
DateTime=新的日期时间(2019、09、29、15、30、0),
时区=“美国/洛杉矶”,
},
End=neweventdatetime()
{
DateTime=新的日期时间(2019、09、30、15、30、0),
时区=“美国/洛杉矶”,
}
,
递归=新字符串[]{
“RRULE:FREQ=每周;BYDAY=MO”
}
,
与会者=新事件与会者[]{
新建EventAttendee(){Email=“gustavooguedareyes@gmail.com"}
}
}
};
公共异步任务crear_evento()
{
字符串[]范围={CalendarService.Scope.Calendar};
ServiceAccountCredential凭证;
字符串filePath=System.Web.Hosting.HostingEnvironment.MapPath(RutaCredentials+jsonFile);
使用(var)流=
新文件流(文件路径、文件模式、打开、文件访问、读取))
{
var confg=Google.api.Json.NewtonsoftJsonSerializer.Instance.Deserialize(流);
凭证=新的ServiceAccountCredential(
新ServiceAccountCredential.初始值设定项(confg.ClientEmail)
{
范围=范围
}.来自PrivateKey(缩写为PrivateKey));
}
var service=new CalendarService(new BaseClientService.Initializer()
{
HttpClientInitializer=凭证,
ApplicationName=“日历API示例”,
});
var myevent=DB.Find(x=>x.Id==“eventid”+3);
var InsertRequest=service.Events.Insert(myevent,calanderId);
尝试
{
InsertRequest.Execute();
}
捕获(例外e)
{
尝试
{
Update(myevent,calanderId,myevent.Id).Execute();
Console.WriteLine(“插入/更新新事件”);
Console.WriteLine(如ToString());
Console.Read();
}
捕获(例外情况除外)
{
Console.WriteLine(例如ToString());
Console.WriteLine(“无法插入/更新新事件”);
}
}
}
}

提供了以下参考解决方案:

超过日历使用限制的
有很多

在您的情况下,一个可能的原因是您添加了一个外部(而不是来自您的域)事件参与者。 为防止垃圾邮件,似乎有以下限制:

此外,目前许多人都遇到了类似的问题,并且已经有一个公开问题跟踪系统。 如果您确定没有超过任何配额限制,则可能是现有的错误导致了您的问题。在这种情况下,我建议您给bug报告加上一个“星”,以提高其可见性,并希望它很快得到修复