How to retrieve Extended Property of the Event in Calendar API v3 for .NET?

2,809 views
Skip to first unread message

Hewbhurt Gabon

unread,
Nov 23, 2014, 8:34:02 AM11/23/14
to google-ca...@googlegroups.com
v2: Added "EventID" as Extended Property so that the event can be updated/deleted later.
ExtendedProperty oExtendedProperty = new ExtendedProperty();
oExtendedProperty
.Name = "EventID";
oExtendedProperty
.Value = myEventID;

v3: Seems this code is the equivalent.
event.ExtendedProperties.Shared.Add("EventID", myEventID);

v2: To search if Google Calendar contains a specific event, use EventQuery object:
string ThisFeedUri = "http://www.google.com/calendar/feeds/" +
 
CalendarID + "/private/full";
Uri postUri = new Uri(ThisFeedUri);
EventQuery Query = new EventQuery(ThisFeedUri);
Query.ExtraParameters = "extq=[EventID:" +
 
GoogleCalendarAppointmentModelObj.EventID + "]";
Query.Uri = postUri;
Entry.ExtensionElements.Add(oExtendedProperty);
EventFeed calFeed = CalService.Query(Query)

v3: This is the NON WORKING example provided by Google Calendar API Team in their documentation for .NET
// Retrieve the event properties.
foreach (KeyValuePair<String, String> sharedProperty in
         
event.getExtendedProperties.Shared) {
 
String sharedName = sharedProperty.Key;
 
String sharedValue = sharedProperty.Value;
}
In Visual Studio 2013, this is the actual available property of the event.
event.ExtendedProperties.Shared


So here I am again. Anyone from here, especially from Google Calendar API team could provide us correct code and a good working example of retrieving Extended Property of an event in Google Calendar.

Lucia Fedorova

unread,
Nov 24, 2014, 8:35:06 PM11/24/14
to google-ca...@googlegroups.com
Hi Hewbhurt,
To query by extended properties you should use:
Query.SharedExtendedProperty = "key=value"

Also as I noticed you are using it for event IDs, maybe it will help you yo know that now it's possible to choose the actual event IDs on inserts: https://developers.google.com/google-apps/calendar/v3/reference/events (check the id property)

Charles Hunt

unread,
Nov 25, 2014, 8:54:24 PM11/25/14
to google-ca...@googlegroups.com
I'm also having an issue with Extended Properties in C#, whether attempting to set or get the values, event.ExtendedProperties turns up null.

event.ExtendedProperties.Private.Add("key", "value"); //trying to set the value

event.ExtendedProperties.Private["key"]; //later, trying to read the value

Do I need to save or attach the property to the event somehow?  Or initialize ExtendedProperties prior to adding/retrieving?

Would appreciate any tips, unfortunately the documentation is rather confusing to me and some things just don't seem to work.  Thank you!

Hewbhurt Gabon

unread,
Nov 25, 2014, 11:22:35 PM11/25/14
to google-ca...@googlegroups.com
Hello ms. Lucia. Thanks for the valuable reply. You are our bestfriend now.

To retrieve the list of available events, we use this code:
Events EventList = service.Events.List(CalendarID).Execute();

To extract and list down individual event, we use this:
foreach (Event ev in EventList.Items)
{              
    strEvent
+= ev.Summary +  " <br> ";
}

My question is: How exactly can we extract the Extended Properties of the EACH event?
Event items only has this 
ev.ExtendedProperties.Shared  

Where did you get the Query in this line of code?
Query.SharedExtendedProperty = "key=value"
What type of object/class is that?

SharedExtendedProperty is accesible in here
service.Events.List(CalendarID).SharedExtendedProperty
which I think lead us to a chance of filtering Events we want to retrieve based on shared Extended Properties key and value as a criteria.

My question again is, how can we extract, where can we assign the value of this SharedExtendedProperty?
Please share us a good and clear example.
Looking forward. Thank you ms. Lucia.

Lucia Fedorova

unread,
Dec 3, 2014, 6:21:21 PM12/3/14
to google-ca...@googlegroups.com
Hi Hewburt,
the fields on the event you are looking for are Google.Apis.Calendar.v3.Data.Event.ExtendedPropertiesData.Private and Google.Apis.Calendar.v3.Data.Event.ExtendedPropertiesData.Shared. The documentation to it: https://developers.google.com/resources/api-libraries/documentation/calendar/v3/csharp/latest/classGoogle_1_1Apis_1_1Calendar_1_1v3_1_1Data_1_1Event_1_1ExtendedPropertiesData.html
The query I mentioned was indeed imprecise, I should have explained that it is Google.Apis.Calendar.v3.EventsResource.ListRequest.PrivateExtendedProperty and Google.Apis.Calendar.v3.EventsResource.ListRequest.SharedExtendedProperty where you can define the filtering.
Please give this a go and if you still can't make it work, please use fiddler (http://www.telerik.com/fiddler) to capture the http requests with responses and post them here (obscuring the private information) together with your code.

Hewbhurt Gabon

unread,
Dec 12, 2014, 9:30:19 AM12/12/14
to google-ca...@googlegroups.com
I will ms. Lucia. Thanks. You are a big help to us. 
I still find it frustrating when Google is forcing us to switch to v3 when the documentation itself is outdated and unprecised and having a migration guide which is ridiculous. I only have weeks left, but I am very far from achieving solution for v3. :(
Message has been deleted

Hewbhurt Gabon

unread,
Dec 12, 2014, 10:55:02 AM12/12/14
to google-ca...@googlegroups.com
Finally, I've got it work!

EventsResource er = new EventsResource(service);
var queryEvent = er.List(CalendarID);

//Property name is "EventID", Property value is "3684"
queryEvent
.SharedExtendedProperty = "EventID=3684";

var EventsList = queryEvent.Execute();

string strEvents = String.Empty;
foreach (Event ev in EventsList.Items)
{
    strEvents
+= ev.Summary + " <br>";
}

Response.Write(strEvents);

Thank you ms. Lucia!
Reply all
Reply to author
Forward
0 new messages