问题
In a .net project, I'm trying to add an event with some attendants with google calendar v3 api. I can create an event without attendants successfully, but when I try to add attendants, it gaves me the following error:
Google.Apis.Requests.RequestError
Calendar usage limits exceeded. [403]
Errors [
Message[Calendar usage limits exceeded.] Location[ - ] Reason[quotaExceeded] Domain[usageLimits]
]
I haven't done any previous request(actually, i have created new gmail accounts and link their respective calendars with their api credentials), and either added more than 5 events.
Here is the code to create an event
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 ");
}
}
}
}
回答1:
Provided the following solution with references:
There are many possible reasons for Calendar usage limits exceeded
In your case, a likely reason is that you add an external (not from your domain) event attendee.
To prevent spamming, there seems to be a the following limit:
Free Google Apps Account For a user: 1 External Guest for 40 Minutes
Also, currently many people are experiencing a similar issue and there is already a filed bug report for this issue on Public Issue tracker.
If you are sure that you are not exceeding any quota limits, it is possible that the existing bug is the reason for your issue. In this case, I suggest you to give a "star" to the bug report to increase its visibility and hope that it will be fixed soon.
来源:https://stackoverflow.com/questions/58177384/403-error-when-inserting-event-with-attendants-in-google-calendar-api-c-sharp