I have my application authenticated using OAuth – and I’ve tested it with the calendar API. Everything works. I also used the “quick add” method for the events API, and that worked fine. But when I tried to insert using the following code
$event = new Event();
$event->setSummary('hello there');
$event->setLocation('America/Los_Angeles');
$start = new EventDateTime();
$start->setDateTime('2012-04-19');
$event->setStart($start);
$createdEvent = $cal->events->insert('myemail@gmail.com', $event);
I get the following error:
Fatal error: Uncaught exception ‘apiServiceException’ with message
‘Error calling POST
https://www.googleapis.com/calendar/v3/calendars/myemail@gmail.com/events?key=AIzaSyBddYIgnZJrXHuT8gvX-0tEypxsycw99rA:
(400) Bad Request’ in
C:\xampp\htdocs\uis\google-api-php-client\src\io\apiREST.php:86 Stack
trace: #0
C:\xampp\htdocs\uis\google-api-php-client\src\io\apiREST.php(56):
apiREST::decodeHttpResponse(Object(apiHttpRequest)) #1
C:\xampp\htdocs\uis\google-api-php-client\src\service\apiServiceResource.php(187):
apiREST::execute(Object(apiServiceRequest)) #2
C:\xampp\htdocs\uis\google-api-php-client\src\contrib\apiCalendarService.php(493):
apiServiceResource->__call(‘insert’, Array) #3
C:\xampp\htdocs\uis\google-api-php-client\examples\calendar\cal.php(44):
EventsServiceResource->insert(‘paine1591@gmail…’, Object(Event)) #4
{main} thrown in
C:\xampp\htdocs\uis\google-api-php-client\src\io\apiREST.php on line
86
with myemail@gmail.com being the ID of my calendar. It works for everything else.
What am I doing wrong?
It appears that you’re not setting the attendees of the event.
Example: