2

There's a method posted here which purportedly enables an app to get an event (copied below for convenience). The event, the link claims will be returned with its resources.

event = service.events().get(calendarId='primary', eventId='eventId').execute()

print event['summary']

What should I provide in place of the string eventId? I created fake events on my calendar (e.g. FakeEvent1 and FakeEvent2) but using FakeEvent2 as a string results in the error event not found.

I know for sure that I am successfully communicating with the Calendar API, because when I use the list method, it returns a list which indeed contains FakeEvent2. The problem is, the name of the event cannot be used as the string 'eventId'. I even tried replacing the name of the event with different properties returned during the list call, like event description and event etag, but to no avail.

Shashank Sawant
  • 1,111
  • 5
  • 22
  • 40
  • On recommendations from the chat I have posted a new question (though it shares the title with an older question). The changes were rejected because they made the question significantly different (hence the recommendation to post it anew). – Shashank Sawant Aug 22 '14 at 07:41

3 Answers3

1

You can get that from the list method, as demonstrated on the documentation page you link to for that method. At the bottom of that page, there is an API explorer: click "Authorise requests" and accept the popup, then put in "primary" in the calendarId field and click execute. You'll see a list of events in your calendar, each of which has an "id" field: you can use that ID in your get method.

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
  • Yes, I have used the `list` method via the api explorer. However, I want to replicate the results on my desktop. How should I go about that? – Shashank Sawant Aug 22 '14 at 16:10
  • I don't understand the question. You can use the list method in your app as well, and get the ids from there to use in the get method, if that's what you want to do. – Daniel Roseman Aug 22 '14 at 16:46
1

When you insert an event through the API, the Events resource returned by the API contains an id parameter, generated by the API servers.

If you created the event manually, then the eventId is harder to find. You can use the list()method with the ?q parameter to search for the event.

I am not a Python developer, but based on these Python examples, I would expect something like this :

service.events().list(calendarId='primary', q='FakeEvent1')
David
  • 5,481
  • 2
  • 20
  • 33
  • What is the syntax to use the `?q` parameter? – Shashank Sawant Aug 22 '14 at 16:08
  • I tried it but I got the result `TypeError: Got an unexpected keyword argument "q"`. So I replaced `q='FakeEvent1'` by `?q='FakeEvent1'` (drawing on your original recommendation), but that resulted in `SyntaxError: invalid syntax` at `?`. Thanks anyways! – Shashank Sawant Aug 23 '14 at 02:22
0

I would like to add that providing "id" gives you the eventId.

i.e.:

print event['id']

I had issues going through a list of events, deleting those within my time search. In the google API overview for list the property name "id" is not included. However calling the list method in the explorer (as suggested by accepted answer) shows the property name listed.