I'm using calendar API v3 and use cURL in PHP with PUT request sending json data. I also have tried updating event using api explorer and it also give me the same error.
I found out that if I put "Content-type: application/json" on the header of my curl request ti gives me different error, the error is like this.
{
"error": {
"errors": [
{
"domain": "global",
"reason": "badRequest",
"message": "Bad Request"
}
],
"code": 400,
"message": "Bad Request"
}
}
here's my code :
$query = {
"kind": "calendar#event",
"id": "eventId",
"etag": "eventEtag",
"status": "confirmed",
"htmlLink": "https://www.google.com/calendar/event?eid=eventEid",
"created": "2011-05-23T22:27:01Z",
"updated": "2011-05-23T22:27:01Z",
"summary": "Appointment at Somewhere",
"location": "Somewhere",
"creator": {
"email": "userEmail"
},
"organizer": {
"email": "userEmail",
"displayName": "userDisplayName"
},
"start": {
"dateTime": "2011-06-03T10:00:00.000-07:00",
"timeZone": "America/Los_Angeles"
},
"end": {
"dateTime": "2011-06-03T10:25:00.000-07:00",
"timeZone": "America/Los_Angeles"
},
"iCalUID": "eventUID",
"sequence": 0,
"attendees": [
{
"email": "attendeeEmail",
"displayName": "attendeeDisplayName",
"responseStatus": "needsAction"
},
# ...
{
"email": "userEmail",
"displayName": "userDisplayName",
"responseStatus": "accepted",
"organizer": true,
"self": true
}
],
"guestsCanInviteOthers": false,
"guestsCanSeeOtherGuests": false,
"reminders": {
"useDefault": true
}
}
$ch = curl_init();
$url = "https://www.googleapis.com/calendar/v3/calendars/calendarId/events/eventId";
$header = "Content-type: application/json";
$putData = tmpfile()
fwrite($putData, $query);
fseek($putData, 0);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_INFILE, $putData);
curl_setopt($ch, CURLOPT_INFILESIZE, strlen($query));
$output = curl_exec($ch);
echo $output;
fclose($putData);
curl_close($ch);