Roberto De Vita
Roberto De Vita

Reputation: 21

Google Calendar API Not removing attendees on the attendees list using Google API Explorer

I'm trying to remove some attendees from a Google Calendar Event, which relates to a room resource calendar, while using the tool on the API documentation Try It API Explorer, properly authorized using a domain admin account which has admin rights over that calendar,

I'm sending a request body deleting two attendees from the event, the API results is 200 OK, but the attendees remains there..

I've tried to add a new attendee or updating it's status and it works ok, but not for removing the attendee..

Any body know what I'm missing here? I've also tried using this through GAS and I'm experiencing the same issue, but to discard any self programming issue I've tried with the official API Try It tool

Request

PATCH
https://www.googleapis.com/calendar/v3/calendars/supportworld.com.ar_34373XXXXXXXXXXX2%40resource.calendar.google.com/events/osrd3lXXXXXXXolks?fields=attendees%2Cid&key={YOUR_API_KEY}

Content-Type:  application/json
Authorization:  Bearer ya29.bwAXXXXXXXXJOeCUAAADDYWT-QXXXXXXXXXXrc_eGP6Lk7CXXXXXXXXJ6130__ci_-_YXXXXxs
X-JavaScript-User-Agent:  Google APIs Explorer

{
 "attendees": [
  {
   "organizer": true,
   "email": "[email protected]",
   "responseStatus": "accepted",
   "displayName": "AAAAAAA"
  },
  {
   "self": true,
   "resource": true,
   "email": "supportworld.com.ar_34373XXXXXXXXXXX2@resource.calendar.google.com",
   "responseStatus": "accepted",
   "displayName": "Cafetera"
  }
 ],
 "id": "osrd3lXXXXXXXolks
"
}

Response

200 OK

cache-control:  no-cache, no-store, max-age=0, must-revalidate
content-encoding:  gzip
content-length:  294
content-type:  application/json; charset=UTF-8
date:  Thu, 28 Aug 2014 16:15:06 GMT
etag:  "XXXXXXXXX"
expires:  Fri, 01 Jan 1990 00:00:00 GMT
pragma:  no-cache
server:  GSE

{
 "id": "osrd3lids0gkoeaggp2c95olks",
 "attendees": [
  {
   "email": "[email protected]",
   "displayName": "AAAAAAA",
   "organizer": true,
   "responseStatus": "accepted"
  },
  {
   "email": "[email protected]",
   "displayName": "YYYYYYY",
   "responseStatus": "accepted"
  },
  {
   "email": "[email protected]",
   "displayName": "BBBBBB",
   "responseStatus": "needsAction"
  },
  {
   "email": "supportworld.com.ar_34373XXXXXXXXXXX2@resource.calendar.google.com",
   "displayName": "Cafetera",
   "self": true,
   "resource": true,
   "responseStatus": "accepted"
  }
 ]
}

the entries:

{
   "email": "[email protected]",
   "displayName": "YYYYYYY",
   "responseStatus": "accepted"
  },
  {
   "email": "[email protected]",
   "displayName": "BBBBBB",
   "responseStatus": "needsAction"
  }

shouldn't be there any more, but they are.. any help on this appreciated,

Upvotes: 2

Views: 1751

Answers (2)

Pavol Brichta
Pavol Brichta

Reputation: 1

I have got it working in C#, I think in other languages it will work the same way.

When I tried to remove the unwanted attendee from the list, it did not work.

eventItem.Attendees.Remove(new EventAttendee { Email = "<to be removed>@gmail.com" });

I imagine you have got to this point.

But when I replaced the list with another list without the attendee, it worked and the other attendees were not even notified about any changes.

eventItem.Attendees = eventItem.Attendees.Where(a => a.Email != "<to be removed>@gmail.com").ToList();

and of course a patch / update afterwards.

service.Events.Patch(eventItem, "primary", eventItem.Id).Execute();

Upvotes: 0

Justin Hong
Justin Hong

Reputation: 383

I was able to get it to work. I think there's an issue with the API explorer tool.

Specifically, where you specify the patch body, there's a structured editor through which you can add and remove sections of the JSON for the attendees object. When I removed an attendee from the list using the structured editor, and then switched over to the freeform editor, the attendee was still there. Bug!

Staying in the freeform editor, I removed the desired attendee block again and executed, and everything worked the way it should. I verified in a separate tab with a GET that the attendee was indeed removed.

(To get to the different editors, there is a drop down button in the top right of the patch body text field.)

Upvotes: 2

Related Questions