我正在尝试使用Ankconnect添加注释,卡片组和模型存在并且字段正确,但是我只是得到了“空”字样(并且未添加卡)。
运行此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
答案 0 :(得分:0)
您的JSON中有一些错误。
将"tags": []
添加到您的每个note对象中,因为根据我所做的测试,这似乎是强制性的,但可以为空。
这至少会为您输出{"result": [null, null, null, null, null], "error": null}
但是随后您需要修复一些字段
"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": []
}
]
}
}