Reputation: 336
I have a c# app which creates events in google calendar. For its own purposes, it controls the event's UID, and sometimes wants to delete and recreate events.
When trying to recreate an event with the same UID as a deleted event, it gets "The remote server returned an error: (409) Conflict."
I can see the deleted events by apending "?showdeleted=true&showhidden=true" to a request URL.
However I do not see anything in the API which allows me to undelete deleted events after retrieving them.
Any suggestions?
UPDATE:
Trying Jay's suggesting I have something like
var service = new CalendarService();
service.setUserCredentials("XXX", "XXX");
var query = new CalendarQuery { Uri = new Uri("http://www.google.com/calendar/feeds/default/owncalendars/full") };
var cal = service.Query(query).Entries
.Select (e => new { Title = e.Title.Text, Uri = e.SelfUri,
Id = e.SelfUri.Content.Split('/').Last () } )
.Single (e => e.Title == calendarName);
var eventQuery = new EventQuery(string.Format(@"http://www.google.com/calendar/feeds/{0}/private/full?showdeleted=true&showhidden=true", cal.Id));
var evs = service.Query(eventQuery).Entries.Cast<EventEntry>().ToList();
evs[0].Status = EventEntry.EventStatus.CONFIRMED;
service.Update(ev[0]);
And it is giving me "The remote server returned an error: (404) Not Found."
Upvotes: 3
Views: 1516
Reputation: 1
The patch operation on the status property seems to fail after deleting/cancelling an event with a 403 error on events that have been deleted some time ago. Setting the status to "cancelled" or deleting the event and then followed by setting the status to "confirmed" for a fresh event worked for me. This behavior is in accordance with the API documentation: "Such cancelled events will eventually disappear, so do not rely on them being available indefinitely. Deleted events are only guaranteed to have the id field populated.".
Joerg
Upvotes: 0
Reputation: 16
It appears that the
The remote server returned an error: (404) Not Found
Is due to the EventEntry.EditUri
not being able to find the deleted / hidden events.
This can be fixed by appending "?showdeleted=true&showhidden=true" to the EditUri
, before the EntryEvent.Update
.
Something along the lines of:
var evs = service.Query(eventQuery).Entries.Cast<EventEntry>().ToList();
evs[0].Status = EventEntry.EventStatus.CONFIRMED;
evs[0].EditUri.Content = evs[0].EditUri.Content + "?showdeleted=true&showhidden=true";
evs[0].Update();
Upvotes: 0
Reputation: 13528
You can undelete an event by changing it's status
attribute from cancelled
to confirmed
You can try this for yourself with an events.patch() operation in the Google API Explorer. You'll need to turn on OAuth authorization and then input the calendar and event IDs.
Upvotes: 5