In my Google calendar, which is in the America/Toronto timezone, I have an event that is marked as an all day on the 13 April 2022, but it is coming back as starting on 2022-04-13 and ending on 2022-04-14. I have some other all day event behaving in the same way.
This is happening from my code, but also when I try with the API test form here:
https://developers.google.com/calendar/api/v3/reference/events/list
With parameters:
timeMin: 2022-04-10T18:36:39.000Z
timeMax: 2022-04-17T18:36:39.000Z
This returns me the following response (certain fields masked):
"kind": "calendar#events",
"etag": "\"p328ftm5rim7ve0g\"",
"summary": "My Test Calendar",
"updated": "2022-04-12T18:36:40.074Z",
"timeZone": "America/Toronto",
"accessRole": "owner",
"defaultReminders": [],
"nextSyncToken": "xxx-xxxx_cCEJD-2LuVj_cCGAUg8t3t0QE=",
"items": [
{
"kind": "calendar#event",
"etag": "\"3299577200148000\"",
"id": "xxxxga02nqb11ub6dm29dgg9t",
"status": "confirmed",
"htmlLink": "https://www.google.com/calendar/event?eid=xxxxxxnYTAybnFiMTF1YjZkbTI5ZGdnOXQgY19uZ2hqOXFzb25tYjRtNDRqN2doaTNxNzY5a0Bn&ctz=UTC",
"created": "2022-04-12T18:36:39.000Z",
"updated": "2022-04-12T18:36:40.074Z",
"summary": "Dummy Event",
"creator": {
"email": "xxxxxx",
"displayName": "xxxxxx"
},
"organizer": {
"email": "xxxxxxx#group.calendar.google.com",
"displayName": "My Test Calendar",
"self": true
},
"start": {
"date": "2022-04-13"
},
"end": {
"date": "2022-04-14"
},
"transparency": "transparent",
"iCalUID": "xxxxx#google.com",
"sequence": 0,
"reminders": {
"useDefault": false
},
"eventType": "default"
}
]
}
I tried providing both 'America/Toronto' and 'UTC' as timeZone parameters in the request, but this does not change anything.
Can anyone suggest how to get an all day event to span only the day it is meant to be happening on?
BTW below you can see the event was only on a single day:
This is an expected behavior from the Calendar API. All day event last for 24 hours. Lasting from midnight of start date to midnight of the next day.
It is also written in the Event Resource that end is exclusive.
An alternative solution to this is to -1 the end date of the response body or manually plot the time. But if you try to manually create an All day event by plotting the time, It can only last for 23.5 hrs.
Related
hi I am using google api to get all the events which is working fine. There is a parameter where I can specify fields name which I need to retrieve. There is a filed named as items where all the events data are coming. Now I want to get specific data of that items filed. Not all the data.
This is how I am getting all the data of that items.
https://www.googleapis.com/calendar/v3/calendars/CALENDAR_ID/events?showDeleted=true&timeMax=2021-08-16T06%3A00%3A46.000Z&timeMin=2021-04-16T06%3A00%3A46.000Z&prettyPrint=true&fields=items&key=[YOUR_API_KEY]
This is how data are coming.
{
"items": [
{
"kind": "calendar#event",
"etag": "\"hfsfjadj\"",
"id": "adfjadfjad",
"status": "confirmed",
"htmlLink": "https://www.google.com/calendar/event?eid=adfjdafjd",
"created": "2021-05-24T05:47:42.000Z",
"updated": "2021-05-24T05:47:42.331Z",
"summary": "dafhafj",
"creator": {
"email": "adfjadfj#gmail.com",
"self": true
},
"organizer": {
"email": "adfjadfj#gmail.com",
"self": true
},
"start": {
"dateTime": "2021-05-24T11:30:00+06:00"
},
"end": {
"dateTime": "2021-05-24T12:30:00+06:00"
},
"iCalUID": "dfjdfjdfj#google.com",
"sequence": 0,
"reminders": {
"useDefault": true
},
"eventType": "default"
}
]
}
I wanted to fetch only id, start,end and summary not the entire thing which is given above.
You can specify nested fields by enclosing them in round brackets, and multiple fields should be separated by commas. Your provided fields would be something like this:
items(id,start,end,summary)
Therefore, the URL would change from this:
https://www.googleapis.com/calendar/v3/calendars/CALENDAR_ID/events?showDeleted=true&timeMax=2021-08-16T06%3A00%3A46.000Z&timeMin=2021-04-16T06%3A00%3A46.000Z&prettyPrint=true&fields=items&key=[YOUR_API_KEY]
To this:
https://www.googleapis.com/calendar/v3/calendars/CALENDAR_ID/events?showDeleted=true&timeMax=2021-08-16T06%3A00%3A46.000Z&timeMin=2021-04-16T06%3A00%3A46.000Z&prettyPrint=true&fields=items(id%2Cstart%2Cend%2Csummary)&key=[YOUR_API_KEY]
Reference:
Partial response
I am hitting events list api on my primary calendar using https://developers.google.com/calendar/v3/reference/events/list, but the response I get is as below -
{
"kind": "calendar#events",
"etag": "\"p32cepg73vamue0g\"",
"summary": "xxxxx#gmail.com",
"updated": "2020-01-31T13:37:23.519Z",
"timeZone": "Asia/Calcutta",
"accessRole": "owner",
"defaultReminders": [
{
"method": "popup",
"minutes": 30
},
{
"method": "email",
"minutes": 30
}
],
"nextPageToken": "CigKGnRwaDY1ajllNm5ldmRtcjJkMmlyMmlwNm40GAEggICA5OuK7f8WGg0IABIAGJjswOP6recCIgcIAhCKnqEB",
"items": []
}
There are a lot of events created in my Calendar, but I am not getting any items returned from the API.
I'm using the Google Calendar API to retrieve events for each of my favorite sports teams. An example calendar can be found here.
When you click on an event, it will show you information about the game, including the TV network it'll be played on, like this:
I'm making a home automation script to automatically detect events and turn on my TV etc., and change to the correct channel. My problem is that when I make a call to the API, the response doesn't include the TV information, each item looks like this:
{
"kind": "calendar#event",
"etag": "\"3014707204000000\"",
"id": "20171021T233000_2017102123",
"status": "confirmed",
"htmlLink": "https://www.google.com/calendar/event?eid=MjAxNzEwMjFUMjMzMDAwXzIwMTcxMDIxMjMgbmhsXzIzXyU1N2FzaGluZ3RvbislNDNhcGl0YWxzI3Nwb3J0c0B2",
"created": "2017-06-22T20:49:57.000Z",
"updated": "2017-10-07T05:20:02.000Z",
"summary": "Panthers # Capitals",
"creator": {
"email": "nhl_23_%57ashington+%43apitals#sports#group.v.calendar.google.com",
"displayName": "Washington Capitals",
"self": true
},
"organizer": {
"email": "nhl_23_%57ashington+%43apitals#sports#group.v.calendar.google.com",
"displayName": "Washington Capitals",
"self": true
},
"start": {
"dateTime": "2017-10-21T19:30:00-04:00"
},
"end": {
"dateTime": "2017-10-21T22:30:00-04:00"
},
"transparency": "transparent",
"visibility": "public",
"iCalUID": "20171021T233000_2017102123#google.com",
"sequence": 0,
"gadget": {
"iconLink": "https://calendar.google.com/googlecalendar/images/sport_hockey.png"
}
}
Does anyone know where this information is stored or if it's retrievable?
Thanks
maybe you can after getting that json reply download the "htmlLink" and parse the line that says TV:
It would be something like this(pseudo code):
Get JSON
Execute something like curl htmlLinkValue | awk '/TV:/' > result.txt
Read that file that will contain the networks.
Regards
I'm trying to test adding an event to my Google Calendar using Google API Explorer page at Google API Explorer - calendar.event.insert
Specifying 'primary' as the calendarId, and enabling 'OAuth 2.0' authorization.
The request body field is as follows:
{
"summary": "Another test",
"start": {
"dateTime": "2017-01-17T11:30:00+02:00"
},
"end": {
"dateTime": "2017-01-17T12:00:00+02:00"
},
"attendees": [
{
"email": "some_mail#some_domain.com"
}
]
}
But when clicking the 'Authorize and Execute' button, I get the following error:
403
- Show headers -
{
"error": {
"errors": [
{
"domain": "usageLimits",
"reason": "quotaExceeded",
"message": "Calendar usage limits exceeded."
}
],
"code": 403,
"message": "Calendar usage limits exceeded."
}
}
If I send the same request but without the 'attendees' part, it works every time.
What am I doing wrong here?
API explorer dumps you into the same quota with everyone else using the api explorer as most of the quotas are project based and its the same project.
You are probably getting it because there are other people testing what you are testing at the same time. There are also limits to what you can test with that. I suspect it wasn't meant to be fully functional.
Also check Calendar usage limits How much have you been testing?
Calendar usage limits exceeded. This is the result of an API call.
(Don't mix this up with the message "Daily quota exceeded," which
points to insufficient API quota.)
Creating too many events
If a user has created more than 10,000 events in his or her calendar
within a short period of time, that user might lose calendar edit
access.
Solution: Send the requests from your own application rather then using api explorer.
What I am sending works fine.
POST https://www.googleapis.com/calendar/v3/calendars/primary/events?sendNotifications=true&key={YOUR_API_KEY}
{
"end": {
"dateTime": "2017-01-17T11:30:00+02:00"
},
"start": {
"dateTime": "2017-01-17T11:30:00+02:00"
},
"attendees": [
{
"email": "ll#xxxx.com"
}
]
}
Response:
200
- Show headers -
{
"kind": "calendar#event",
"etag": "\"2969293763864000\"",
"id": "did1s0f76g79s1ht5aplhieoik",
"status": "confirmed",
"htmlLink": "https://www.google.com/calendar/event?eid=ZGlkMXMwZjc2Zzc5czFodDVhcGxoaWVvaWsgbGF1cmx5NzFAbQa",
"created": "2017-01-17T09:54:41.000Z",
"updated": "2017-01-17T09:54:41.932Z",
"creator": {
"email": "xxxx#gmail.com",
"displayName": "Linda Lawton",
"self": true
},
"organizer": {
"email": "xxxxx#gmail.com",
"displayName": "Linda Lawton",
"self": true
},
"start": {
"dateTime": "2017-01-17T10:30:00+01:00"
},
"end": {
"dateTime": "2017-01-17T10:30:00+01:00"
},
"iCalUID": "1s0f76g79s1ht5aplhieoik#google.com",
"sequence": 0,
"attendees": [
{
"email": "ll#xxxxx",
"responseStatus": "needsAction"
}
],
"reminders": {
"useDefault": true
}
}
I've updated this because this question makes more sense than the original. I'm still including the test code that I used to show what's happening.
Please see the comments for more up to date information on what I've found.
Executed API to grab events for today (there should be 1):
/calendar/v3/calendars/{calid}/events?calendarId={calid}&singleEvents=true&timeMin=2013-04-24T00:00:00.000Z&timeMax=2013-04-25T00:00:00.000Z
It retrieves nothing. No events are returned.
If I execute the following (ie, the next day):
/calendar/v3/calendars/{calid}/events?calendarId={calid}&singleEvents=true&timeMin=2013-04-25T00:00:00.000Z&timeMax=2013-04-26T00:00:00.000Z
It retrieves the following which is set for the 24th (yet after 7pm), not the 25th:
{
"kind": "calendar#events",
"etag": "\"GZxpEFttRDAOmLHnWRxLHHWPGwk/01XVNYQjwJ5jTmd05uIgK9e6Uhw\"",
"summary": "test calendar",
"description": "test calendar",
"updated": "2013-04-24T13:09:12.000Z",
"timeZone": "America/Chicago",
"items": [
{
"kind": "calendar#event",
"etag": "\"GZxpEFttRDAOmLHnWRxLHHWPGwk/Z2NhbDAwMDAxMzY2MTQ4ODczODI3MDAw\"",
"id": "d1mdj3dasor22f0nm0lbohru7s",
"status": "confirmed",
"htmlLink": "https://www.google.com/calendar/event?eid=ZDFtZGozZGFzb3IyMmYwbm0wbGJvaHJ1N3MgYnZzdG9vbHMuY29tX2xidWt1ZmlnczJjMmFycjViODgycDVhYWhvQGc",
"created": "2013-04-16T21:47:53.000Z",
"updated": "2013-04-16T21:47:53.827Z",
"summary": "this should happen 4/24/2013",
"description": "testing event",
"creator": {
"email": "{my email address}",
"displayName": "my name"
},
"organizer": {
"email": "{calid}",
"displayName": "test calendar",
"self": true
},
"start": {
"dateTime": "2013-04-24T21:21:19-05:00"
},
"end": {
"dateTime": "2013-04-24T21:21:19-05:00"
},
"iCalUID": "d1mdj3dasor22f0nm0lbohru7s#google.com",
"sequence": 0,
"extendedProperties": {
"private": {
"evtKey": "key"
}
},
"reminders": {
"useDefault": true
}
}
]
}
It should be retrieving it for the first api call on the 24th, not the 2nd api call on the 25th unless I'm missing something.
Any ideas? Thanks!
a bit late but if you still needs it. I think the event you retrieved d1mdj3dasor22f0nm0lbohru7 seems to be in default timezone of the calendar, which is America/Chicago. That explains why it only showed when you set your query to 25th UTC time