Cancelled Google Calendar Event empty properties and missing extendedproperties - google-api

When fetching a list of Google Calendar Events (v3) using a syncToken, most properties of the returned event are empty when its status is 'cancelled'.
For my synchronisation programme, I need to be able to get my unique key from the ExtendedProperties collection. This property seems to be missing from the Event. I could, of course, use the ICalUID to match both records, but that means rewriting the whole thing.
Is there a way to get all the properties the Event once had when its status is now Cancelled?

You should get all the properties by setting showDeleted=true on the list request.

Related

Is there a way to retrieve G Suite resources usage information per user?

In our organizational G Suite service, we defined rooms in "Building and Resources".
We schedule meetings in these rooms through Google Calendar.
Is it possible to get an organized report, that shows room usage per user? We would like to know which user used which room and for how many hours per time unit (month). Is there a way to get this information? An organized report? Any form of raw data?
We could only find general high-level data about the usage of each room, but no specific user data.
Issue:
There's no built-in method to retrieve this information.
If you think this feature could be useful, I'd suggest you to file a feature request on this Issue Tracker component.
Workaround:
Even though there's currently no direct method to retrieve an organized report for this, you could retrieve the information about how much a resource is being used by the different users, using Calendar API.
You could do the following:
A Calendar is created for each resource. This Calendar contains all events in which the resource is present (a resource can be added as an attendee for the event, or the event can be directly created on the resource calendar; either way, all events will be present in the resource calendar). Find the corresponding calendar ID by clicking Settings and sharing for the calendar, and scrolling to the section Integrate calendar.
Call Events: list, setting the calendarId property to the ID you retrieved in previous step. This will return all events in which this resource has been used. You could also retrieve the events between a specific time interval, by specifying the properties timeMin and timeMax.
Each event in this retrieved list will have information about: (1) the event attendees, including its organizer (check the attendees property on the Events resource), and (2) the event start and end time (check the properties start and end). With this information, you can know which users used each resource and for how much time. You'd just need to filter the events according to the attendees, and calculate the event durations using the start and end dates.
Repeat steps 1 to 3 for each resource.
Update:
Feature request reported on Issue Tracker:
Report resources usage information per user

Google Calendar Watch and Events working together

I am creating a Node/Express Webapp that would mirror a user's calendar. It would get a notification for every change in the users calendar, and would update the DB with the latest of that user's calendar.
Lets assume that we want to monitor john.doe#gmail.com. Kindly tell me if this is the best (and only) way to do it:
Set up for Push notification - While doing so, we provide (amongst other fields):
token - A plain-text that would be echoed back. This is where I can put something like 'calOwner=john.doe#gmail.com'
id - A UUID channel id
Upon every change, my webhook will get a push notification that would contain:
token : calOwner=john.doe#gmail.com
id : the channelId - I dont understand if this field alone can be used to trace this notification message back to john.doe#gmail.com
Now that I know john.doe#gmail.com has changed, I would do a list with a synchToken. This will return me the change in john's calendar since last synch
What baffles me here is that the seemingly important fields channelId and resourceId (which appears as x-goog-resource-id in the push notification header) are useless, and the only field that ties the push message to list is an optional plain-text field token .
Kindly tell me if this is the only way to track a user's calendar.
UPDATE
Thanks #KENdi for the answer.
My struggle was with the point that simply looking at a push notification message, there is no way to trace it back to john.doe#gmail.com . I now understand why such is the case, that a push notification does not contain the calendarId, but the resourceId instead (which, in plain terms is the event object). It is so because an event can be associated with multiple calendars, and hence multiple calendarIds. Hence, it is the subscriber's responsibility to maintain association of the channel to the calendarId that he had used to create the channel at the first place.
Yes, you are correct, you need the calendar push notification, to notify you about all the changes happened in the Google Calendar.
The purpose of X-Goog-Resource-ID is an opaque value that identifies the watched resource. And this ID is stable across API versions.
Check this SO question to know more about the purpose of X-Goog-Resource-Id.

Office 365 API Not All Events Being Received

I am using the Outlook Calendar REST API to retrieve calendar events.
When I call the url https://outlook.office365.com/api/v2.0/users/#{email}/calendarview?endDateTime=2016-09-01T10:00&startDateTime=2016-08-10T10:00
I get only the single event instances returned. How can I include the occurrences of repeating events too?
The calendar view REST gets the occurrences, exceptions, and single instances of events in a calendar view defined by a time range. It works well for me. Please check whether the time range is correct to filter the view.
In addition, you can check the type of event type in the response. It should be Occurrence in this scenario.
Update: test with Microsoft Account

Is there a way to uniquely identify a picture attached to an Outlook ContactItem?

It is my understanding that an Outlook contact's "avatar" image is stored as an Attachment object in the Attachments collection (ref).
Now suppose, as an example, that I want to keep my own (separate) contact database updated whenever the user's Outlook contacts change, so I'm registered for a PropertyChange event on the ContactItem. Is there any way to determine whether or not the picture attached to a ContactItem has changed, or do I need to call SaveAsFile() on the ContactPicture.jpg Attachment every time that I get a change notification, just on the off chance that it may have been updated?
There is no any kind of CRC of the attachment data, so you won't know if the actual binary data has changed. You can read the Attachment.Size property, and if it is different from what you had before, the data has changed for sure.
You can also read the PR_CREATION_TIME and PR_LAST_MODIFICATION_TIME properties using Attachment.PropertyAccessor.GetProperty, but these properties are not requires and can stay the same even if the data has changed.

Efficient way of syncing Gmail Inbox messages using the new Gmail API?

A web application sends an email on behalf of a UserA to UserB, using the new Gmail API (Users.messages: send).
The synchronous response contains threadId, messageId which are stored in the database.
We then query the history API for any changes in user's inbox (Users.history: list).
Is there an efficient way to get all the updates since last sync (new replies, read/unread changes)?
One implementation that we tried was to filter the history API results through a custom label. Unfortunately, we noticed that once a thread/message is tagged with a specific label any subsequent responses are not labeled automatically and new replies are not included in the history API response.
A second approach was to query threads using gmail advanced search for a particular label and date (e.g. after:2014/08/29 label:MY_LABEL). The problem was that gmail does not return threads that were created before 2014/08/29 but had a reply on that date.
Any scalable suggestions would be greatly appreciated.
Not sure I understand here, users.history.list was made exactly for this. Given a previous historyId, you can then call history.list(previousHistoryid), iterate through the results to find all the message Ids that have been updated since the previous historyId. Then call messages.get() on all of those--for any messages you already knew about you can just call format=MINIMAL (to see label updates), and for new messages you can use a different format to get the message content if you need it.

Resources