【问题标题】:Google Calendar API Event Insertion谷歌日历 API 事件插入
【发布时间】:2012-10-10 16:51:53
【问题描述】:

我在尝试将事件插入日历时遇到问题。这是我到目前为止的代码,取自 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();

除了我不断得到

        Exception in thread "main"     

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

"message" : "Invalid Value"

我做错了什么?

【问题讨论】:

  • 这可能是由一个格式错误的字段引起的。您是否尝试过省略某些字段以隔离导致问题的字段?

标签: java google-calendar-api google-api-java-client


【解决方案1】:

你试过这个吗?

attendees.add(new EventAttendee().setEmail("attendeeEmail@bla.com"));

我重现了这个错误:谷歌似乎在检查电子邮件中是否有 @ 符号。 添加@bla.com 为我解决了这个问题。不再有 400 错误请求

【讨论】:

    猜你喜欢
    • 2018-09-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-08-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多