我们一直在使用相同的流程创建一年的Google日历邀请,如果日历邀请和ID已经存在,它将创建一个新的。
此代码相当静态,所以我想知道谷歌的API上是否发生了可能发生变化的事情?
这是返回的错误:
{
"ExceptionDetail": {
"HelpLink": null,
"InnerException": null,
"Message": "Google.Apis.Requests.RequestError The requested identifier already exists. [409] Errors [Message[The requested identifier already exists.] Location[ - ] Reason[duplicate] Domain[global]]",
"Type": "Google.GoogleApiException"
},
"ExceptionType": "Google.GoogleApiException",
"Message": "Google.Apis.Requests.RequestError The requested identifier already exists. [409] Errors [Message[The requested identifier already exists.] Location[ - ] Reason[duplicate] Domain[global]]",
以下是创建/更新邀请
的代码片段 service = Authentication.AuthenticateOauth();
//Google calendar ID for calendar request.
EventsResource.ListRequest checkIfMade = service.Events.List(newCalendar.calendarID);
Events events = checkIfMade.Execute();
var hasBeenMade = false;
foreach (var eventItem in events.Items)
{
if (eventItem.Id == convertedID)
{
hasBeenMade = true;
break;
}
}
if (hasBeenMade)
{
EventsResource.UpdateRequest singleEventRequest = new EventsResource.UpdateRequest(service, myEvent, newCalendar.calendarID, myEvent.Id);
singleEventRequest.SendNotifications = true;
singleEventRequest.Execute();
// Debug.Print(eventLink.HtmlLink);
}
else
{
EventsResource.InsertRequest singleEventRequest = new EventsResource.InsertRequest(service, myEvent, newCalendar.calendarID);
singleEventRequest.SendNotifications = true;
singleEventRequest.Execute();
//Debug.Print(eventLink.HtmlLink);
}
}