designersheep

SHARD_UNAVAILABLE when filtering with tags (Java API 1.23)

8 posts in this topic

I get SHARD_UNAVAILABLE exception when trying to filter by tags.  It gives me correct results when I filter using notebooks but tag always throws me either a permission denied (if I use empty token), or shard unavailable if I use my normal token.  Is there a way to get a token for a public notebook?  I don't have this problem when I am trying to access privately shared notebooks.
 
This code below works:
 

 

               filter.setNotebookGuid(filterGUID);                NoteList notes = authInfo.noteStore.findNotes(authInfo.accessToken, filter, 0, maxNotes); 

 

The code below doesn't:

 

 

                ArrayList<String> tagList = new ArrayList<String>();                tagList.add(t.getGuid());                filter.setTagGuids(tagList);                NoteList notes = authInfo.noteStore.findNotes(authInfo.accessToken, filter, 0, maxNotes); 

 

Exception:

 
EDAMSystemException(errorCode:SHARD_UNAVAILABLE, message:s202)    at com.evernote.edam.notestore.NoteStore$findNotes_result.read(NoteStore.java:11762)    at com.evernote.edam.notestore.NoteStore$Client.recv_findNotes(NoteStore.java:1153)    at com.evernote.edam.notestore.NoteStore$Client.findNotes(NoteStore.java:1125) 

or when using empty token

 

EDAMUserException(errorCode:PERMISSION_DENIED, parameter:authenticationToken)    at com.evernote.edam.notestore.NoteStore$findNotes_result.read(NoteStore.java:11754)    at com.evernote.edam.notestore.NoteStore$Client.recv_findNotes(NoteStore.java:1153)    at com.evernote.edam.notestore.NoteStore$Client.findNotes(NoteStore.java:1125) 

Any help would be highly appreciated :)

Share this post


Link to post

The equivalent PHP code works for me (I don't have a java platform to test on right now).

But I'm not on the same shard so...

Share this post


Link to post

This code works for me :

 

/**       * Retrieve and display a list of the user's notes by tag.       */      private void listNotesByTags()        throws Exception      {        // List the notes in the user's account        System.out.println("Listing notes by tags:");        // First, get a list of all notebooks        //List<Notebook> notebooks = noteStore.listNotebooks(authToken);        NoteFilter filter = new NoteFilter();        ArrayList<String> tagList = new ArrayList<String>();        tagList.add("03d37ca1-c81d-458a-b523-5cac84d085dd");        filter.setTagGuids(tagList);        NoteList noteList = noteStore.findNotes(authToken, filter, 0, 10);        List<Note> notes = noteList.getNotes();        for (Note note : notes) {          System.out.println(" * " + note.getTitle());        }        System.out.println();      }

Share this post


Link to post

If you were using the production service, there was a brief interruption that might have caused that. More info here

Share this post


Link to post

Thanks everyone, but it's still not working for me.  Perhaps I'm doing something wrong when I'm creating the notestore.  Strangest thing is that it works for privately shared notebook.

 

From my exception stack trace above, the error message says s202, but the tag resides in s212.  I did use s202 accessToken though, because it won't accept an empty string for the token, whereas when I am doing a findNotes with notebook ID as filter it WOULD accept an empty access token.  Is there a way to create a valid access token for s212 when I have access to it as a publicly shared notebook?

 

// I use this code to create the notestore, where url is the url to the correct shard (s212)THttpClient noteStoreTrans = new THttpClient(url);TBinaryProtocol noteStoreProt = new TBinaryProtocol(noteStoreTrans);newNoteStore = new NoteStore.Client(noteStoreProt, noteStoreProt);...// and I use the code below for accessing privately shared notebooks, but it throws exception on publicly shared notebooks and I've been just using an empty token so far until I ran into this tag based find problemAuthenticationResult res = linkedStore.authenticateToSharedNotebook(nb.getShareKey(), accessToken);newToken = res.getAuthenticationToken();

Share this post


Link to post

I'm not sure that I exactly understand what you're trying to do but here are a few things to consider :

 

- when you're accessing a privately shared notebook you need a shareKey because it's ... private.

- when you're accessing a public notebook you don't need a shareKey because everyone can access it.

 

so, in your case, you don't need to get a token or anything else to access this public notebook.

 

All you have to do when you want to find notes in a public notebook is setting the notebook guid in addition to you other filter parameters.

So this code should work :

 

THttpClient noteStoreTrans = new THttpClient("http://www.evernote.com/edam/note/s212");TBinaryProtocol noteStoreProt = new TBinaryProtocol(noteStoreTrans);noteStore = new NoteStore.Client(noteStoreProt, noteStoreProt);NoteFilter filter = new NoteFilter();ArrayList<String> tagList = new ArrayList<String>();tagList.add(%the_tag_guid%);filter.setTagGuids(tagList);filter.setNotebookGuid(%the_public_notebook_guid%);NoteList noteList = noteStore.findNotes("", filter, 0, 10);

 

At least, it works for me ;)

1 person likes this

Share this post


Link to post

Thank you Laurent,

 

Your latest code worked for me, only difference being that I had to set the notebook GUID on the filter, which I didn't need to do for privately shared notes.  Now it is working great!

Share this post


Link to post