Adding a new card with Python not working

I’m trying to add a new card with Python

        card_id = 123456789 
        model = mw.col.models.by_name("Basic")
        new_note = mw.col.newNote(model)

        new_note["Front"] = "Front content of the card"
        mw.col.add_note(new_note, card_id)

The model variable retrieves the correct card type, however, when I use it in new_note, it retrieves an entirely random card type (cloze overlapping), does anyone know what could be causing it or what am I doing wrong?

The deprecated .newNote() doesn’t take a model argument. Instead, it uses the model most recently used for the current deck if its first argument (forDeck) is True, which explains why you’re getting a note of a different type. You should use .new_note() instead.

Also note that the second argument to .add_note() is a deck ID rather than a card ID.


This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.