Ankiconnect 不会添加备注
Ankiconnect will not add note
我正在尝试使用 Ankconnect 添加注释,牌组和模型存在且字段正确,但我只是 "null" 返回(并且未添加卡片)。
运行 这个 bash 脚本
echo "---------- The deck exists:"
curl localhost:8765 -X POST -d '{
"action": "getDeckConfig",
"version": 6,
"params": {
"deck": "Foo"
}
}'
echo "---------- The model exists:"
curl localhost:8765 -X POST -d '{
"action": "modelFieldNames",
"version": 6,
"params": {
"modelName": "Auto-generated"
}
}'
echo "---------- But adding a card fails:"
curl localhost:8765 -X POST -d '{
"action": "addNotes",
"version": 6,
"params": {
"notes": {
"deckName": "Foo",
"modelName": "Auto-generated",
"fields": {
"Question": "why?",
"Answer": "because!",
"Card ID": "foo"
},
"options": {
"allowDuplicate": true
},
}
}
}'
产生这些结果
------------ 牌组存在:
{"result": {"dyn": false, "usn": 82, "timer": 0, "replayq": true, "name": "Default", "id": 1, "lapse": {"mult": 0.0, "minInt": 1, "delays": [10], "leechAction": 0, "leechFails": 8}, "autoplay": true, "rev": {"hardFactor": 1.2, "ivlFct": 1.0, "ease4": 1.3, "perDay": 200, "fuzz": 0.05, "minSpace": 1, "bury": false, "maxIvl": 36500}, "mod": 1560476298, "maxTaken": 60, "new": {"ints": [1, 4, 7], "perDay": 20, "delays": [1, 10], "order": 1, "initialFactor": 2500, "bury": false, "separate": true, "LBGIMinBefore": 1, "LBGIMinAfter": 1, "LBEIMinBefore": 4, "LBEIMinAfter": 4}}, "error": null}
------------ 模型存在:
{"result": ["Question", "Answer", "Card ID"], "error": null}
------------ 但是加卡失败:
null
您的 JSON 中存在一些错误。
将 "tags": []
添加到您的每个笔记对象,因为根据我所做的测试,它似乎是强制性的,但可以为空。
这至少会让你得到 {"result": [null, null, null, null, null], "error": null}
的输出
但是你需要修复一些字段
- "addNotes" 采用 "notes" 个对象的数组,但您将单个对象分配给
"notes"
而不是数组。
"modelName"
不能"Auto-generated"
改成"Basic"
"Question"
应该是 "Front"
"Answer"
应该是 "Back"
你的 curl 调用中的对象应该是这样的:
{
"action": "addNotes",
"version": 6,
"params": {
"notes": [
{
"deckName": "Foo",
"modelName": "Basic",
"fields": {
"Front": "why?",
"Back": "because!",
"Card ID": "foo"
},
"options": {
"allowDuplicate": true
},
"tags": []
}
]
}
}
我正在尝试使用 Ankconnect 添加注释,牌组和模型存在且字段正确,但我只是 "null" 返回(并且未添加卡片)。
运行 这个 bash 脚本
echo "---------- The deck exists:"
curl localhost:8765 -X POST -d '{
"action": "getDeckConfig",
"version": 6,
"params": {
"deck": "Foo"
}
}'
echo "---------- The model exists:"
curl localhost:8765 -X POST -d '{
"action": "modelFieldNames",
"version": 6,
"params": {
"modelName": "Auto-generated"
}
}'
echo "---------- But adding a card fails:"
curl localhost:8765 -X POST -d '{
"action": "addNotes",
"version": 6,
"params": {
"notes": {
"deckName": "Foo",
"modelName": "Auto-generated",
"fields": {
"Question": "why?",
"Answer": "because!",
"Card ID": "foo"
},
"options": {
"allowDuplicate": true
},
}
}
}'
产生这些结果
------------ 牌组存在:
{"result": {"dyn": false, "usn": 82, "timer": 0, "replayq": true, "name": "Default", "id": 1, "lapse": {"mult": 0.0, "minInt": 1, "delays": [10], "leechAction": 0, "leechFails": 8}, "autoplay": true, "rev": {"hardFactor": 1.2, "ivlFct": 1.0, "ease4": 1.3, "perDay": 200, "fuzz": 0.05, "minSpace": 1, "bury": false, "maxIvl": 36500}, "mod": 1560476298, "maxTaken": 60, "new": {"ints": [1, 4, 7], "perDay": 20, "delays": [1, 10], "order": 1, "initialFactor": 2500, "bury": false, "separate": true, "LBGIMinBefore": 1, "LBGIMinAfter": 1, "LBEIMinBefore": 4, "LBEIMinAfter": 4}}, "error": null}
------------ 模型存在:
{"result": ["Question", "Answer", "Card ID"], "error": null}
------------ 但是加卡失败:
null
您的 JSON 中存在一些错误。
将 "tags": []
添加到您的每个笔记对象,因为根据我所做的测试,它似乎是强制性的,但可以为空。
这至少会让你得到 {"result": [null, null, null, null, null], "error": null}
但是你需要修复一些字段
- "addNotes" 采用 "notes" 个对象的数组,但您将单个对象分配给
"notes"
而不是数组。 "modelName"
不能"Auto-generated"
改成"Basic"
"Question"
应该是"Front"
"Answer"
应该是"Back"
你的 curl 调用中的对象应该是这样的:
{
"action": "addNotes",
"version": 6,
"params": {
"notes": [
{
"deckName": "Foo",
"modelName": "Basic",
"fields": {
"Front": "why?",
"Back": "because!",
"Card ID": "foo"
},
"options": {
"allowDuplicate": true
},
"tags": []
}
]
}
}