#Gcal GET failing

1 messages Β· Page 1 of 1 (latest)

night sinew
#

I can share the kotlin code, but for debugging I even use Postman and Curl and still the result of the GET is negative.

For example:

curl -X GET "https://www.googleapis.com/calendar/v3/calendars/${calendar}/events?maxResults=1" \
  -H "Authorization: Bearer  ${GCtoken}"\
  -H "Content-Type: application/json"

this return 200OK response and the calendar info like last updated, but with zero items on it.

I know the access token and calendar are correct, as I can see the update time change when I do a new POST. Still the GET returns empty

onyx prairie
#

try without the maxResults for a sec

night sinew
#

Now even the timeMin thing does not work

onyx prairie
#

hm, thats weird, Google wouldnt make breaking changes to a versioned API

night sinew
#

There is no changes in the release note neither

onyx prairie
#

and it's 100% pointing to the correct calendar id?

night sinew
#

I'm using a Service Account for auth is this is relevant

onyx prairie
#

nah, should be fine, you're getting 200 OK so it shouldnt be related to auth

#

POST to it real quick w the same calendar ID you're using in the listings and check that it shows up in the expected calendar

night sinew
#

I do it again wait a sec, just for testing

#
curl -X POST "https://www.googleapis.com/calendar/v3/calendars/${calendar}/events" \
  -H "Authorization: Bearer ${GCtoken}" \
  -H "Content-Type: application/json" \
  -d '{
        "summary": "Test Event",
        "description": "This is a test event created via API",
        "start": {
          "dateTime": "2025-01-16T10:00:00+02:00",
          "timeZone": "Europe/Helsinki"
        },
        "end": {
          "dateTime": "2025-01-16T11:00:00+02:00",
          "timeZone": "Europe/Helsinki"
        }
      }'

This works and I can see the new event the 16 of january.

After that a GET to /events return empty

onyx prairie
#

hm, i'll try to reproduce this

#

sec

#

in the meantime, can you try it with an API key instead? it shouldn't be the probem, but worth a try - could be different credentials not having permissions and it just goes ehh, let's send a 200

#

when debugging, everything is worth a try :}

#

ah nvm the API doesn't support API keys - then I'm equally confused

#

@tulip stratus thoughts?

night sinew
onyx prairie
#

nah, all good, shouldnt be an auth issue

#

i was just trying something out

onyx prairie
night sinew
#

404 πŸ˜‚

onyx prairie
#

waht

#

fun

#

very fun

#

hm

night sinew
#

sorry I used this

curl -X GET "https://calendar-json.googleapis.com/calendars/${calendar}/events" \
  -H "Authorization: Bearer  ${GCtoken}"\
  -H "Content-Type: application/json"
#

is that correct?

onyx prairie
#

should be, according to the discovery doc

#

one sec again

night sinew
#

so maybe the calendar ID is incorrect, this is the last line

...
<p><b>404.</b> <ins>That’s an error.</ins>
  <p>The requested URL <code>/calendars/MY_GAL_ID/events</code> was not found on this server.  <ins>That’s all we know.</ins>
onyx prairie
night sinew
onyx prairie
#

Neil might know better than me on this, I've pinged him already

#

Now we waitt πŸ™ƒ

night sinew
#

Alright! thank you anyway for the help, really really grateful. It has been very frustrating the whole day 😭 . I'm so hyped with the code part and now this has been a bumper

#

I will try now with normal Auth2, let's see if I manage to make it work and it actually works

onyx prairie
#

Keep me updated! This is puzzling me too, I'd like to know what works ;)

night sinew
#

Small update. I continued testing with the Service Account, and until now everything works. I managed to debug this

ALL these work!
GET https://www.googleapis.com/calendar/v3/calendars/${calendar}/events?pageToken=CkAKMAouCgwIt-u6uwYQwMX47QESHgocChpvODJrOGpscm9iMDJrM2FzYW5wcGZubzJsMBoMCJTVv7sGEICVkJkDwD4B
GET https://www.googleapis.com/calendar/v3/calendars/${calendar}/events?showDeleted=true
GET https://www.googleapis.com/calendar/v3/calendars/${calendar}/events?singleEvents=true

These still do not work
GET "https://www.googleapis.com/calendar/v3/calendars/${calendar}/events"
GET "https://www.googleapis.com/calendar/v3/calendars/${calendar}/events?timeMin=2024-01-01T00:00:00Z&timeMax=2025-12-31T23:59:59Z"

So, I've decided to add the singleEvents=true and continue the development, as I managed to GET and DELETE all the events as I wanted.

Still, I cannot understand the behaviour, as any of my events has any recurring field.

Let's see if Neil or anyone else can bring light to the problem

tulip stratus
tulip stratus
night sinew
# tulip stratus Just to be sure I got it right, this specific request doesn't reply with any eve...

Sorry for my bad wording, still got to learn the backend jargon πŸ˜… . When I use a GET call into /events endpoint, the output is this

{
 "kind": "calendar#events",
 "etag": "\"p32g9dm64nn58k0o\"",
 "summary": "Event42Sync",
 "description": "",
 "updated": "2024-12-28T12:37:44.628Z",
 "timeZone": "Europe/Helsinki",
 "accessRole": "writer",
 "defaultReminders": [],
 "nextPageToken": "CkAKMAouCgwIt-u6uwYQwMX47QESHgocChpvODJrOGpscm9iMDJrM2FzYW5wcGZubzJsMBoMCJjiv7sGEICKuqsCwD4B",
 "items": []
}

So the call "works" but the items array is empty. But THERE ARE events in the calendar.

After the debugging, if I use /events?singleEvents=true, then this header shows, but also all the events in the items array.

In previous iterations of the code I always used GET in the /events and worked fine to fetch everything.

Does my explanation make sense?

tulip stratus
night sinew
tulip stratus
#

Have you tried looking at the next pages?

#

I think that all the events may be on the next pages πŸ€”

night sinew
tulip stratus
#

The way I understand the API, every request only returns up to maxResults events (by default 250, max 2500).

#

Many APIs (including this one) split the results in many requests, because you rarely want one single request to get every single event for all time

#

For instance if I did that in my personal or work calendar, I would have thousands upon thousands of events listed ahah

#

So the API allows you to show the first page, then the next one, then another one, until there is no page left anymore kind of :)

#

The parameter singleEvents makes it so if you have a recurring event, it won't show every repeated event as an event, but only the first one created kind of

#

It basically allows to expand or not the events

#

What I think is happening in your case

night sinew
#

Thanks for the explanation, this is what I called "pagination". Maybe that is not the word πŸ˜… . But does not this mean I shall fetch the "first" 250 entries?

Yes, the singleEvents I understood, but I have no recurring ones

tulip stratus
#

Is that you have singleEvents=false (by default)

#

And showDeleted=false (by default too)

#

And maybe your first 250 events are a single event that repeated once every day for a year or something like that

#

(so 365 events!)

#

But since you're not showing the deleted ones (showDeleted=false) then nothing is returned

#

Thus the first 250 events are deleted events (part of the 365 ones created)

#

When you set singleEvents=True though, it collapses all of them into a single "repeating" event

#

thus instead of counting as 365 events, it counts as 1, allowing you to see other events on the first page, without having to go to the next pages

#

(tell me if my explanation doesn't make too much sense -- I typed this quite quickly in the train ahah)

night sinew
#

Okey... this makes some sense. For clarity, all the events in this calendar have been POST one by one using my program. I've been adding and deleting them multiple times, as I develop the code. In any case, I have used nothing related to recurring. In each batc,h there are around 60 events.

I assume that single and delete parameters are not changed anywhere, but used in the call. Until now I did not use them for anything.

Your explanation makes much sense because I have deleted many events. So basically the whole first page is full of deleted events and without using the delete=true, it does not show those, so the first page is just a "void" of 250 "void" entries.

Is this what you mean?

#

Still don't get why the singleEvents also solve the issue, as there are no recurring events AFAIK. Maybe deleted events are also batched into one or something.

tulip stratus
#

Maybe you could check by showing all the hidden ones (showDeleted & showInvitations if i remember correctly), just to see what kind of events show up

night sinew
#

OK OK OK!! this makes so much sense now. I still have to research more but at least you confirmed that my code works as intended, the API and Auth are working as intended and that I need to learn much more πŸ˜†πŸ˜†πŸ˜†

#

I'm so happy!! you cannot imagine how much debugging and googling i've done

#

I'm not crazy πŸ€– !

tulip stratus
#

ahah no problem :D

tulip stratus
tulip stratus
night sinew
#

thank you so much to you and @onyx prairie ! I did good trying to join this community

#

Is there any better way to get this kind of help? seem that this is more a social than technical forum

#

So I don't bother people here

tulip stratus
#

But yeah this kind of "pagination" system with filters as parameters is quite common, as many use cases don't necessarily want all the events/results, but only the first ones so it loads quickly, and then they only load the next one when the user scrolls down / goes to the next page / clicks "show more" / ...

tulip stratus
#

Stackoverflow can be a good solution

#

Also we have a channel dedicated to workspace here: #workspace :)

#

So it's best to ask those questions there or on other forums like stackoverflow in my opinion

night sinew
#

These answers are super useful, I will follow your advice

#

πŸ™‡ THANK YOU!!!!!!!!

onyx prairie
#

That's... Really weird

#

Why does it not fully remove it?

#

This also explains why it suddenly just stopped working

#

Super interesting, had no idea

onyx prairie
#

As for the social vs technical aspect, that's just because we started this convo in the sorta general chat

#

Check the other channels, this server is basically a technical (&social) forum for all things Google :)

tulip stratus
#

Let's say you have an app that displays all your events in a scrollable list

#

What you'll want to do is show the first 250 items then as the user scrolls you load more of them and "stitch them together'

#

But then if the user hides or shows the hidden elements

#

You want to keep the same page system

#

So the user scroll position doesn't suddenly shift

tulip stratus
#

@fervent mirage