要访问ExtendedProperties,我需要通知完整的投影。 我见过的每个例子都是通过URL完成的: https://developers.google.com/google-apps/calendar/v2/reference#Event_feeds
https://www.google.com/calendar/feeds/userID/visibility/projection
但我没有那个网址。我按如下方式创建服务:
Calendar createService() throws GeneralSecurityException, IOException {
GoogleCredential credential = new GoogleCredential.Builder()
.setTransport(HTTP_TRANSPORT).setJsonFactory(JSON_FACTORY)
.setServiceAccountId(EMAIL)
.setServiceAccountScopes(CalendarScopes.CALENDAR)
.setServiceAccountPrivateKeyFromP12File(new File(getClass().getClassLoader().getResource(FILE_NAME).getFile()))
.build();
Calendar service = new Calendar.Builder(HTTP_TRANSPORT, JSON_FACTORY, credential)
.setApplicationName("Rokko-Leggis")
.build();
return service;
}
我尝试保存并检索ExtendedProperty但失败了
如何保存自定义字段?
答案 0 :(得分:1)
实测!
ExtendedProperties extended = new ExtendedProperties();
Map<String, String> map = new HashMap<>();
map.put("customField", "customValue");
extended.setShared(map);
event.setExtendedProperties(extended);
答案 1 :(得分:0)
你可以用两行来做到这一点:
this.calendarEvent.setExtendedProperties(new ExtendedProperties().setShared(extendedPropertiesMap));