2011-09-11 5 views
1

Google 캘린더 API를 사용하여 일정을 수정하고 싶습니다. 이 예에서 일정 편집 할 수있는 코드가 있었다 :Android에서 Google 캘린더 일정을 수정하는 방법은 무엇입니까?

Entry executePatchRelativeToOriginal(Entry updated, Entry original) throws IOException { 
    AtomPatchRelativeToOriginalContent content = new AtomPatchRelativeToOriginalContent(); 
    content.namespaceDictionary = DICTIONARY; 
    content.originalEntry = original; 
    content.patchedEntry = updated; 
    HttpRequest request = 
     requestFactory.buildPatchRequest(new GenericUrl(updated.getEditLink()), content); 
    return request.execute().parseAs(updated.getClass()); 

내가 편집 일정을 원한다면 그것은 작동하지만 편집 이벤트와 작동하지 않습니다 내가 가진 예외 : 물론

09-11 17:29:13.516: WARN/System.err(15787): com.google.api.client.http.HttpResponseException: 403 Forbidden 

이벤트를 편집 할 수있는 강점이 있습니다. 또한 같은 방법으로 캘린더를 삭제하려면 delete 이벤트가 적용됩니다. 삭제 기능 :

public void executeDelete(Entry entry) throws IOException { 
    HttpRequest request = requestFactory.buildDeleteRequest(new GenericUrl(entry.getEditLink())); 
    request.execute().ignore(); 
} 

아이디어가 있으십니까?

답변

0

문제가 해결되었습니다. 저는 Atom에서 HTTP PATCH 대신 HTTP PUT을 사용하고 객체의 다른 인스턴스를 생성하는 대신 원래 이벤트 을 수정했습니다.

public EventEntry executePutUpdateEvent(EventEntry updated) throws IOException { 
AtomContent content = new AtomContent(); 
content.namespaceDictionary = DICTIONARY; 
content.entry = updated; 
HttpRequest request = 
    requestFactory.buildPutRequest(new GenericUrl(updated.getEditLink()), content); 
return request.execute().parseAs(updated.getClass());} 
: 여기

는 작업 코드
관련 문제