FooSoft / anki-connect

Anki plugin to expose a remote API for creating flash cards.
https://foosoft.net/projects/anki-connect/
Other
1.94k stars 220 forks source link

addNote error: Exception: cannot create note because it is empty #240

Open valuex opened 3 years ago

valuex commented 3 years ago

I've update AnkiConnect for Anki 2.1.38 today. And get an error message as:

Exception: cannot create note because it is empty

Kindly help to point out how to fix it, thanks.

#!/usr/bin/env python

import util

def runTest():
    options = {
        'allowDuplicate': True
    }

    note1 = {
        'deckName': 'NewWords',
        'modelName': 'Basic',
        'fields': {'Front': 'front1', 'Back': 'back1'},
        'tags': ['tag1'],
        'options': options
    }

    # addNote
    noteId = util.invoke('addNote', note=note1)

if __name__ == '__main__':
   runTest()
valuex commented 3 years ago

Huh, My fault. I changed the fields name as Front and Back, and get it solved.