// 使用 @larksuiteoapi/node-sdk 更新飞书文档 - 尝试不同的块结构 import lark from '/home/ubuntu/.openclaw/extensions/openclaw-lark/node_modules/@larksuiteoapi/node-sdk/lib/index.js'; const APP_ID = 'cli_a93eb0f160399cc5'; const APP_SECRET = 'dRzJKrJ46j2Y1DKneyC33dQUNmsLwHCj'; const DOC_ID = 'YerQd8GomoDWQ6xA1zTc31xfnwb'; // 表格内容 (Markdown 格式) const TABLE_CONTENT = `| 日期 | 规格 | 数量 | |------|------|------| | 24 年 12 月 | 细和润 | 2 | | 24 年 12 月 | 金细 | 1 | | 24 年 12 月 | 红中支 | 3 | | 25 年 | 细和润 | 2 | | 25 年 | 双支 | 5 | **总计**: 13`; async function main() { try { console.log('创建 Lark Client...'); const client = new lark.Client({ appId: APP_ID, appSecret: APP_SECRET, }); // 尝试使用简单的文本块 console.log('正在添加文本块...'); const createBlockRes = await client.docx.documentBlockChildren.create({ params: {}, data: { blocks: [ { block_type: 1, // text text: { elements: [ { text_run: { content: TABLE_CONTENT, }, }, ], }, }, ], }, path: { document_id: DOC_ID, block_id: DOC_ID, }, }); console.log('添加块响应:', JSON.stringify(createBlockRes, null, 2)); if (createBlockRes.code !== 0) { console.error('添加块失败:', createBlockRes.msg); console.error('错误详情:', JSON.stringify(createBlockRes.error, null, 2)); return; } console.log('✓ 文档更新成功!'); } catch (error) { console.error('✗ 发生错误:', error.message); // 打印更多错误详情 if (error.response) { console.error('响应状态:', error.response.status); console.error('响应数据:', JSON.stringify(error.response.data, null, 2)); } console.error(error.stack); process.exit(1); } } main();