简体   繁体   English

Google Calendar API事件插入

[英]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: 这是我到目前为止的代码,取自Google API帮助:

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. 添加@ bla.com解决了它。 no more 400 Bad Request 没有更多400错误请求

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM