I think I am missing something obvious so hopefully this is an easy
one.
I have a .net application (asp.net) that is submitting calendar events
to my Google Calendar. When I create the event, I return the full
(selfURI) and store it in my own database as the Google Calendar
identifier. What is the best way to delete this event? I've tried 2
things:
1. If I reference the event using the full selfURI and I try to delete
it I get the error saying I cannot delete a read-only event.
2. I can send this URI to a service that retrieves all events (using
client login method) and then matches the URI as I loop through the
events. I can then delete the event.
Number 2 above works just fine but has obvious performance
implications. If I want to delete 1 event I have to retrieve
minimally the events for a day or time frame which seems like overkill
(get back 20 items to delete 1). How can I query for just the single
event (I have the full URI) and delete it? I really want to know how
to query for a single event without getting the event in read-only
mode.
**Code for method #2 is posted below:
Thanks,
Jon Stonis
try
{
CalendarService service = new
CalendarService("TreeStone");
service.setUserCredentials("[email protected]",
"xxxxx");
EventQuery query = new EventQuery();
query.Uri = new Uri("https://www.google.com/calendar/
feeds/default/private/full"); // Tell the service to query:
EventFeed calFeed = service.Query(query);
if (calFeed != null)
{
foreach (EventEntry entry in calFeed.Entries) //
NOTE: I have to loop through numerous events here to delete 1.
{
if (entry.SelfUri == "https://www.google.com/
calendar/feeds/default/private/full/hcotlemaqvgbebnscq6b12bbt4") //
URI is Hard coded to do a unit test.
{
entry.Delete();
MessageBox.Show("Deleted");
}
}
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message + ex.StackTrace);
}
--
You received this message because you are subscribed to the Google
Groups "Google Calendar Data API" group.
To post to this group, send email to
[email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://code.google.com/apis/calendar/community/forum.html