在LinkedNotebook中创建Notes

时间:2016-10-20 10:45:11

标签: android evernote

我正在尝试在已经与我共享的共享笔记本中创建笔记。笔记本与我共享,以修改其内容(SharedNotebookPrivilegeLevel.MODIFY_NOTEBOOK_PLUS_ACTIVITY),我可以使用Evernote Web客户端在该笔记本中创建笔记。但是当我尝试使用SDK创建一个笔记时,我收到了一个EDAMUserException(errorCode:PERMISSION_DENIED,参数:authenticationToken)。以下是我的代码

Note note = new Note();
note.setContent(EvernoteUtil.NOTE_PREFIX + content + EvernoteUtil.NOTE_SUFFIX);
note.setTitle(title);
EvernoteSession evernoteSession = EvernoteSession.getInstance();
List<LinkedNotebook> linkedNotebooks = evernoteSession
        .getEvernoteClientFactory()
        .getNoteStoreClient()
        .listLinkedNotebooks();
LinkedNotebook current = null;
for (LinkedNotebook linkedNotebook : linkedNotebooks) {
    if (linkedNotebook.getShareName().equals(notebookName)) {
        current = linkedNotebook;
    }
}
if (current == null)
    throw new IllegalStateException();
THttpClient tHttpClient = new THttpClient(current.getNoteStoreUrl());
TBinaryProtocol tBinaryProtocol = new TBinaryProtocol(tHttpClient);
NoteStore.Client client = new NoteStore.Client(tBinaryProtocol, tBinaryProtocol);
AuthenticationResult authenticationResult = client.authenticateToSharedNotebook(current.getShareKey(),
        evernoteSession.getAuthToken());
String shareToken = authenticationResult.getAuthenticationToken();
SharedNotebook sharedNotebook = client.getSharedNotebookByAuth(shareToken);
String sharedNotebookGuid = sharedNotebook.getNotebookGuid();
note.setGuid(sharedNotebookGuid);
Note createdNote = client.createNote(shareToken, note);
return createdNote;

我已使用this文章创建笔记。

1 个答案:

答案 0 :(得分:1)

我发现的一个错误是

note.setGuid(sharedNotebookGuid);

必须是

note.setNotebookGuid(sharedNotebookGuid);