- Issue created by @RustedBucket
- 🇮🇳India sadashiv
Hi,
I would suggest trying minor change
Use
$postBody = new \Google\Service\Calendar\Calendar();
or
$postBody = new \Google_Service_Calendar_Calendar();
instead of
$postBody = new \Google_Service_Calendar_CalendarListEntry();
and the api call change to
$service->calendars->patch($calendar_id, $postBody);
so the final code should look like
$google_api_service_client = \Drupal::entityTypeManager()->getStorage('google_api_service_client')->load('my_service_account'); $googleService = \Drupal::service('google_api_service_client.client'); $googleService->setGoogleApiClient($google_api_service_client); $googleService->googleClient->setSubject($calendar_id); $service = new \Google_Service_Calendar($googleService->googleClient); // THIS WORKS: This will return the calendar information fine $service->calendarList->get($calendar_id); $postBody = new \Google_Service_Calendar_Calendar(); $postBody->setDescription('Some new description'); $service->calendars->patch($calendar_id, $postBody);
Hth,
Sadashiv - 🇺🇸United States RustedBucket
So using the Google_Service_Calendar_Calendar class does work. However, that set apis only exposes a very limited amount of Calendar data as compared the Google_Service_Calendar_CalendarListEntry. Not that it is a big deal but the fact one can't update via $service->calendarList->patch seems problematic. For instance, if one wanted to update the backgroundColor that isn't part of the Calendar_Calendar class so you have to use Calendar_CalendarListEntry.
Also, is there an easy way to capture the raw request and response objects by chance?
Thanks
- Status changed to Closed: works as designed
over 1 year ago 6:18am 1 March 2023 - 🇮🇳India sadashiv
Hi @RustedBucket,
I think you are trying to operate on calendar fields so you need to use Calendar API, CalendarList is something different.
You can read google documentations at https://developers.google.com/calendar/api/concepts/events-calendars#cal...
https://developers.google.com/calendar/api/v3/reference/calendarList/update
https://developers.google.com/calendar/api/v3/reference/calendars/update
etcFrom the Documentation Description can't be set using the CalendarList but is supported only by Calendar, The php api client library has the function but that is out of the scope of this module and can be reported to the library github.
Thanks,
Sadashiv.