Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

updateNoteFields returns errorless but does nothing #82

Open
zacharied opened this issue Jun 17, 2018 · 16 comments
Open

updateNoteFields returns errorless but does nothing #82

zacharied opened this issue Jun 17, 2018 · 16 comments

Comments

@zacharied
Copy link

zacharied commented Jun 17, 2018

I have been trying to write a program that inserts example sentences into a vocabulary deck using a few APIs, but have gotten hung up because updateNoteFields seems to do nothing. I can run noteInfo and get the note's information fine, but running updateNoteFields on the same note ID seems to do nothing. The request also returns "error": null despite clearly not following intended behavior.

@zacharied zacharied changed the title updateNoteFields does nothing updateNoteFields returns 200 but does nothing Jun 17, 2018
@zacharied zacharied changed the title updateNoteFields returns 200 but does nothing updateNoteFields returns errorless but does nothing Jun 17, 2018
@sintak
Copy link

sintak commented Jul 13, 2018

I try this Action, and then it returns: {result: null, error: 'NoneType' object is not iterable}

@redstoneleo
Copy link

I met with the same issue , but the cause in my case is I got the wrong note id( an id doesn't exist at all).
One could check with

findNotes

Returns an array of note IDs for a given query. Same query syntax as guiBrowse.

Sample request:

{
"action": "findNotes",
"version": 6,
"params": {
"query": "deck:current"
}
}
Sample result:

{
"result": [1483959289817, 1483959291695],
"error": null
}

@masteranza
Copy link

masteranza commented Mar 24, 2019

Try adding modelName and deckName. Works for me now.

@garrett-hopper
Copy link

I'm observing the same behavior with the latest master branch.

@garrett-hopper
Copy link

After doing some debugging, it looks like the ankiNote is updated with the correct fields, but nothing is updated upon ankiNote.flush().

@garrett-hopper
Copy link

I should not I'm on Anki 2.1.11.

@FooSoft
Copy link
Owner

FooSoft commented Jun 8, 2019

Just tested this on 2.1.13 and it appears to work fine for me. Can you try running the unit test and see if that fails for you (check test.sh).

@garrett-hopper
Copy link

Ah, it appears it doesn't work when the note browser is open. If I close the browser and then update a note, I can open it again and view the updated note.

@FooSoft
Copy link
Owner

FooSoft commented Jun 9, 2019

The note browser probably resets the note to the previous value on close.

@garrett-hopper
Copy link

That'd make sense; I wonder if there's a way to live-update in the browser.
I suppose it's not really important for normal usage though.

@shanehh
Copy link

shanehh commented May 30, 2020

The note browser probably resets the note to the previous value on close.

It works for me now, Thank you!

@eyeinsky
Copy link
Contributor

eyeinsky commented Nov 1, 2020

I was struggling with the same issue with Anki 2.1.15 on Linux, and what @garrett-hopper says is correct: if the note browser is open then just running updateNoteFields doesn't appear to update the card in the browser.

Some additional observations:

  • if after the seemingly failed update one runs a successful addNote while the note browser still open, then both changes happen successfully (i.e are reflected in the note browser);
  • but if you close note browser and then run a successful addNote then the update is lost.

I wonder if this means that the update request is received but simply not shown in the note browser. And then when one closes the note browser it takes all the data from the note browser's view and overwrites the update -- effectively going back to the old value.

@FooSoft Perhaps this is a bug in the Anki program itself?

@kondeeza
Copy link

kondeeza commented Nov 23, 2020

Could I suggest adding some clear warning in updateNoteFields's section of notes.md that having note browser would likely cause the note to not be updated even if the API returns a successful promise? I have a feeling first timer user and developer alike would be very tempted to keep browser gui open to handily see if the command works (which would backfire XD)

@Twinov
Copy link
Contributor

Twinov commented Jul 26, 2021

Can I bump the request to add a warning to updateNoteFields in the README that having the GUI open causes it to not do anything? I just ran into this exact issue, ironically also writing a script to add example sentences to a vocabulary deck. Closing the GUI solved the issue though so thanks Garrett!

@Aquafina-water-bottle
Copy link
Contributor

Just wanted to mention that for anyone writing scripts using updateNoteFields that there is a workaround: You can run guiBrowse to essentially refresh Anki's browser.

The order of API calls is the following:

  • guiBrowse with a query of nid:1 (or some other invalid note id, to clear the browser window)
  • updateNoteFields
  • guiBrowse with a query of nid:<your note id that you just updated>

Credits to this code in mpvacious for pointing it out in the comments.

@chenlijun99
Copy link

Perhaps it is case-sensitive and you should use "Basic" instead of "basic"?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests