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?
Have you tried this instead?
attendees.add(new EventAttendee().setEmail("attendeeEmail@bla.com"));
I reproduced the error: it seems google checks emails for an @ sign. adding @bla.com solved it for me. no more 400 Bad Request
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.