Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Calendar API - can only update event once

I've encountered the same problem as described in this post:

Google Calendar api v3 re-update issue

Namely, once I create an event and update it once using the Google Calendar API (v3), I am no longer able to update the event. When I attempt to, I get a 400 - Invalid value response. (FWIW I'm working in PHP).

Following a lead offered in the post I referenced above, I attempted to solve the issue using etags (though admittedly my grasp of how they work is limited). Basically, on event update, the API returns an etag in its response, which I now save in my database. Then for subsequent (n > 1) updates, I pull the current etag from the database and include it in the http header:

Content-Type:  application/json
Authorization:  OAuth [token]
If-Match: [etag]

This follows info under the "Updating Entries" header here: http://code.google.com/apis/gdata/docs/2.0/reference.html#ResourceVersioning

Sidenote: in the google ref above, the If-Match header is shown as

If-Match: "S0wCTlpIIip7ImA0X0QI"

with double quotes around the etag. I'm saving the etags in the database with double quotes, exactly as I receive them in first update response. Do I need to escape the quotes or anything when adding to the header using curl_setopt/HTTPHEADER?

Despite implementing this etag If-Match thing, I'm still getting the same 400 - Invalid value response. I know that my request bodies are valid because the first update works fine. There's just some additional issue surrounding subsequent updates.

Any help much appreciated.

like image 808
G.S. Avatar asked Dec 10 '22 01:12

G.S.


1 Answers

Make sure to increment the sequence number field when updating events.

like image 189
lucia Avatar answered Dec 13 '22 23:12

lucia