Reputation: 5311
I am working on a Java project where I am integrating Evernote services. Right now, I am able to save, update notes, but what I would like to do is to search notes. Now, As evernote is tied to our infrastructure, I would like to save an ID of the object whose text we are copying to Evernote.
So, whenever the text is updated, I would like to get the same Note from Evernote and update it's contents. These are the two problems I am facing :
Here is some of the saving and searching code I have so far :
Note note = new Note();
note.setTitle("New title");
String nBody = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>";
nBody += "<!DOCTYPE en-note SYSTEM \"http://xml.evernote.com/pub/enml2.dtd\">";
nBody += "<en-note>" + "Test" + "</en-note>";
note.setContent(nBody);
note.setGuid("1234");
Note savedNote = noteStoreClient.createNote(note);
Search code :
NoteFilter noteFilter = new NoteFilter();
// AS you can see, I have no idea what filter to set here.
// noteFilter.getTagGuids(id);
NoteList noteList = noteStoreClient.findNotes(noteFilter,0,100);
List<Note> notes = noteList.getNotes();
for(Note note : notes){
System.out.println("Note title is "+note.getTitle());
}
Kindly let me know what I can do. Thanks a lot. :-)
Udpate
This happens when I try to save the GUID with my own randomly created one. Error log :
EDAMUserException(errorCode:BAD_DATA_FORMAT, parameter:Note.guid)
at com.evernote.edam.notestore.NoteStore$getNote_result.read(NoteStore.java:13514)
at com.evernote.edam.notestore.NoteStore$Client.recv_getNote(NoteStore.java:1346)
at com.evernote.edam.notestore.NoteStore$Client.getNote(NoteStore.java:1316)
at com.evernote.clients.NoteStoreClient.getNote(NoteStoreClient.java:368)
at com.journaldev.spring.service.EvernoteServiceImpl.findNoteById(EvernoteServiceImpl.java:157)
Upvotes: 1
Views: 133
Reputation: 1157
You can't set a manually assigned guid on a note when creating it - guids are assigned by the service and returned on the Note object as part of the createNote call on NoteStore.
As an aside, guids have a certain format, see the format here.
Upvotes: 2