iCloud-API icon indicating copy to clipboard operation
iCloud-API copied to clipboard

Note with missing shortGUID is not handled

Open zudljk opened this issue 4 years ago • 2 comments

When a note that has no shortGUID field is passed to Notes.resolve(...), the iCloud will respond with a HTTP 400, the response payload of which is not handled in Notes.resolve(), leading to a follow-up error (see #51 )

Invalid data in a note should be handled before submitting the resolve request to the server.

zudljk avatar Sep 05 '20 18:09 zudljk

Where exactely in a note object is this shortGUID field located? I can't find it. Thanks a lot!

JOJ0 avatar Oct 16 '20 05:10 JOJ0

It's directly below the note object; this is my workaround:

      notes.on("end", async zone => {

        if (notes.folders.length > 0) {
            var folders = notes.folders.filter(f => !f.recordName.startsWith("TrashFolder"));
            folders.forEach(async folder => {
                createFolderDir(folder.recordName);
                folder.notes
                    .filter(n => n.shortGUID)
                    .map(note => myCloud.Notes
                        .resolve(note)
                        .then(pv => pv.forEach(pve => saveNote(pve))
                        )
                    );
            });
        }

      });

zudljk avatar Nov 06 '20 08:11 zudljk