我正在尝试通过 OneNote API 创建新页面。我正在关注Microsoft 教程和文档。
似乎 header() 不起作用。
图教程\graph.js:
createPage: async function(sectionID, content, accessToken) {
const client = getAuthenticatedClient(accessToken);
console.log('DEBUG:', '[Creating Pages]', sectionID);
const res = await client
.api(`/me/onenote/sections/${sectionID}/pages`)
.header({
'Content-type': 'application/xhtml+xml'
})
.post(content);
return res;
}
路线\onenote.js:
let content =
`<!DOCTYPE html>
<html>
<head>
<title>${subject}</title>
<meta name="created" content="${creationDate}" />
</head>
<body>
${description}
</body>
</html>`
let page = await graph.createPage(section.id, content, accessToken);
错误:
{ statusCode: 400,
code: 'BadRequest',
message: 'Unable to read JSON request payload. Please ensure Content-Type header is set and payload is of valid JSON format.'
.... }