更新正文
const got = await mn.api('/notes/batch-get', { method: 'POST', body: { noteIds: [noteid] } });
const own = (got.items[0].texts || []).find(t => t.index === 0) || {};
const before = String(own.text || '').slice(0, 32);
const r = await mn.api('/notes/' + noteid + '/text', {
method: 'POST',
body: { text: '光合作用把光能转成化学能。', expectedPrefix: before, confirm: true }
});
// 正文里不要写标签控制行,会被 HASHTAG_ROUTE_REQUIRED 拒
if (r.error && r.error.code === 'HASHTAG_ROUTE_REQUIRED') {
mn.log(r.error.details.writeRoute);
}{
"groupCacheUpdated": true,
"groupCachesUpdated": 1
}卡片与摘录
更新卡片正文
改该卡的正文。留白实体的正文也用该接口写入,目标传 kind 为留白的那一项的 id。
expectedPrefix 是当前正文的前 32 个字,为空传空串。内容已变时返回 409。
不要通过该接口写入标签。正文里出现标签控制行会被 422 HASHTAG_ROUTE_REQUIRED 拒绝,
响应会注明应当改用哪个接口。修改正文之前须先确认该卡是否为摘录卡,看 texts[].excerpt
或内容来源里的 hasExcerpt,不依据页码。
POST
/
notes
/
{noteid}
/
text
更新正文
const got = await mn.api('/notes/batch-get', { method: 'POST', body: { noteIds: [noteid] } });
const own = (got.items[0].texts || []).find(t => t.index === 0) || {};
const before = String(own.text || '').slice(0, 32);
const r = await mn.api('/notes/' + noteid + '/text', {
method: 'POST',
body: { text: '光合作用把光能转成化学能。', expectedPrefix: before, confirm: true }
});
// 正文里不要写标签控制行,会被 HASHTAG_ROUTE_REQUIRED 拒
if (r.error && r.error.code === 'HASHTAG_ROUTE_REQUIRED') {
mn.log(r.error.details.writeRoute);
}{
"groupCacheUpdated": true,
"groupCachesUpdated": 1
}路径参数
卡片的 noteid。取自卡片命令响应的 noteid、POST /notes/batch-get 响应里 items[].noteid,或 GET /ui-state 的 state.focusnoteid。
请求体
application/json