2011-05-20 43 views
0

使用Java Google日曆API時出現異常,我無法做出正面或反面。我在做的是創建一個插入事件的Google Calendar的連接器。其中一些事件正在重複,其中一些事件對重複模式有例外。我在創建事件和重複事件方面非常成功,但在嘗試制定例外時遇到了這些問題。Google日曆API中的「元素必須包含屬性ID的值」

我正在使用的代碼是:

CalendarEventEntry gglAppt = new CalendarEventEntry(); 
OriginalEvent originallink = new OriginalEvent(); 
originallink.setOriginalId(repeatingEvent.getIcalUID()); 
When originalWhen = new When(); 

originalWhen.setStartTime(DateTime.parseDate("2011-05-01")); 
originallink.setOriginalStartTime(originalWhen); 

When exceptionWhen = new When(); 
exceptionWhen.setStartTime(DateTime.parseDate("2011-05-10")); 

gglAppt.setOriginalEvent(originallink); 
gglAppt.setStatus(EventStatus.CANCELED); 
gglAppt.addTime(exceptionWhen); 

try { 
    //I can vouch for this line, it works elsewhere in the code. 
    //CalendarServiceManager is a custom class if you didn't guess ;-) 
    CalendarServiceManager.getInstance().addNewEvent(gglAppt, http://www.google.com/calendar/feeds/default/calendars/testemail%40gmail.com); 
} catch (IOException e) { 
    e.printStackTrace(); 
} catch (ServiceException e) { 
    e.printStackTrace(); 
} 

唯一的例外是:

com.google.gdata.util.InvalidEntryException: Bad Request 
Element must contain value for attribute id 
at com.google.gdata.client.http.HttpGDataRequest.handleErrorResponse(HttpGDataRequest.java:594) 
at com.google.gdata.client.http.GoogleGDataRequest.handleErrorResponse(GoogleGDataRequest.java:563) 
at com.google.gdata.client.http.HttpGDataRequest.checkResponse(HttpGDataRequest.java:552) 
at com.google.gdata.client.http.HttpGDataRequest.execute(HttpGDataRequest.java:530) 
at com.google.gdata.client.http.GoogleGDataRequest.execute(GoogleGDataRequest.java:535) 
at com.google.gdata.client.Service.insert(Service.java:1409) 
at com.google.gdata.client.GoogleService.insert(GoogleService.java:599) 
at com.testapp.google.CalendarServiceManager.addNewEvent(CalendarServiceManager.java:138) 
at com.testapp.google.GoogleAdapter.dealWithExceptions(GoogleAdapter.java:581) 
...etc 

我從我周圍的interwebs看到的理解是,一個屬性ID是你設置的東西用於Google對象,以便跟蹤它們。我不知道在哪裏設置屬性ID,我很困惑爲什麼我不必爲我提交的其他任何事件設置屬性ID。

這是什麼異常被拋出?這是什麼意思,我該怎麼辦?

任何幫助將不勝感激一如既往。

+0

也發佈了此問題http://code.google.com/apis/calendar/community/forum.html?place=topic%2Fgoogle-calendar-help-dataapi%2FvD6xahZq8ms%2Fdiscussion – atraudes 2011-05-20 17:14:37

回答

相關問題