0
votes

I had my Google calendar application almost working, I am still able to list all the events on the Primary Calendar and I can edit on Google and see the updated results on my calendar.

The problem is that my: var eventToUpdate = gapi.client.calendar.events.get({

is getting an error 404.

From what I've been reading people who have had this issue previously were sending the wrong Key or wrong Event ID. But I've tested the values using

https://developers.google.com/calendar/v3/reference/events/update

& I get a success 200 back from Google.

Here is my event drop:

eventDrop: function( eventDropInfo ) { 
gapi.auth.setToken('<?php echo $google_auth['access_token']; ?>');  
handleAuthClick;
gapi.client.init({
    apiKey: API_KEY,
    clientId: CLIENT_ID,
    discoveryDocs: DISCOVERY_DOCS,
    scope: SCOPES
}).then(function () { 

}, function(error) { 
   appendPre(JSON.stringify(error, null, 2));
});
                updateSigninStatus(gapi.auth2.getAuthInstance().isSignedIn.get());  
var eventToUpdate = gapi.client.calendar.events.get({
    "calendarId": 'primary', 
    "eventId": eventDropInfo.id 
});  

There's more but that's the main Google APIs part.

I thought it could be the Key, however the Key works to grab the calendar information and is able to be used for my other Google stuff. (Drive, Login etc.)

I thought maybee it was the wrong calendar ID but using the Google "Try This API" It seems the Calendar ID + Event ID is perfect as Google gives me success.

Below you can see the console error, apologies if I've missed off anything important.

Thank You!

Error 404 From Console --- Updated with more info

This shows Google References accepting the event ID and updating the event

This is the data I've entered to get the 200 success above

This is the URL showing the JSON google print out

Just to note, I've checked the scopes and the 2 I am using are:

var SCOPES = "https://www.googleapis.com/auth/calendar https://www.googleapis.com/auth/calendar.events";

The only others I can find are Read Only so I doubt it's the scopes.

Also the code seems to work as the only error I see is Google giving a 404, the loading of the events and calendar work it's just update that gives the 404.

As you can see through the screenshots I've updated the event ID i'm using to test is the same in my code as in the References test.

1
Just a heads up that Google is having issues with their calendar service right now.. maybe why you're getting a 404? google.com/…Chockomonkey
This Google Calendar API is back up, are you still getting the 404?Chockomonkey
What scopes are you using? Maybe calendar information is a more restrictive scope than event details.user835611
Can you use the API Explorer for get instead of for update to see if it works?user835611
Thank you for the suggestions, I have retested today and I still get the 404 from my API script and then 200 from the Google API Test page. The scope I will have a look into but I doubt it's that as it worked prior to yesterday and the scopes I have set allow me to lookup and find the events. (I get this still might be restricted so I'll see if there is any more I can use.) Also I already do a GET to get all of the event data, am I able to use GET to update an event also ? I presumed GET was for getting the events and update was to update them.Ryan Thompson

1 Answers

0
votes

This is now working.

The problem was with my script not setting the OAuth Token correctly. It was saving the full JSON string instead of just the token.

After amending the login and getting the correct OAuth it works as it should :)

Thanks for the help!