Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Calendar API Event Insertion

I am having problems trying to insert events into a calendar. Here is the code I have so far, taken from the Google API help:

Event event = new Event();
event.setSummary("Appointment");
event.setLocation("Somewhere");
ArrayList<EventAttendee> attendees = new ArrayList<EventAttendee>();
attendees.add(new EventAttendee().setEmail("attendeeEmail"));
event.setAttendees(attendees);
Date startDate = new Date();
Date endDate = new Date(startDate.getTime() + 3600000);
DateTime start = new DateTime(startDate, TimeZone.getTimeZone("UTC"));
event.setStart(new EventDateTime().setDateTime(start));
DateTime end = new DateTime(endDate, TimeZone.getTimeZone("UTC"));
event.setEnd(new EventDateTime().setDateTime(end));
service.events().insert("primary", event).execute();

Except I keep getting

        Exception in thread "main"     

    com.google.api.client.googleapis.json.GoogleJsonResponseException: 400 Bad Request

"message" : "Invalid Value"

What am I doing wrong?

like image 715
user1760919 Avatar asked May 08 '26 21:05

user1760919


1 Answers

Have you tried this instead?

attendees.add(new EventAttendee().setEmail("[email protected]"));

I reproduced the error: it seems google checks emails for an @ sign. adding @bla.com solved it for me. no more 400 Bad Request

like image 169
Arjan Franzen Avatar answered May 10 '26 10:05

Arjan Franzen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!