[英]Delete page's content with Onenote Rest API
I haven't found a way to delete items from a page's content with the onennote API. 我还没有找到一种使用onennote API从页面内容中删除项目的方法。
Let's say my page's content is 假设我页面的内容是
<body>
<div id="div:{681ddef6-e8ad-0de3-2439-dcc668303696}{34}">
<p id="p:{f5837c83-d816-4337-ab6d-a52abde869a6}{13}">Delete me</p>
<p id="p:{1710a020-7fa3-46cb-a8ab-64209696e083}{14}">Keep me/p>
</div>
</body>
I can build a PATCH
request to insert, append, preprend, ... but that are no instructions to delete content. 我可以建立一个
PATCH
请求来插入,追加,预先添加...,但这并不是删除内容的说明。
I tried to replace the paragraph by some empty content: 我试图用一些空内容替换该段:
[{
'target': 'p:{f5837c83-d816-4337-ab6d-a52abde869a6}{13}',
'action': 'replace',
'content': ' '
},
]
but this leads to an error: 但这会导致错误:
{
"error":{
"code":"20121","message":"The PATCH argument $content: is invalid.","@api.url":"http://aka.ms/onenote-errors#C20121"
}
}
Any suggestion ? 有什么建议吗? Thanks.
谢谢。
Just looking at this in the microsoft graph, you can replace the content with a HTML line break. 只需在Microsoft图表中查看,就可以用HTML换行符替换内容。
[{
'target': 'p:{f5837c83-d816-4337-ab6d-a52abde869a6}{13}',
'action': 'replace',
'content': '<br/>
'
}]
While the API does not support the "DELETE" action in PATCH pages (I'd encourage you to add an entry in our uservoice webpage https://onenote.uservoice.com/forums/245490-onenote-developer-apis ), you can replace the entire page with whatever new content you want it to have. 尽管该API不支持PATCH页面中的“删除”操作(我鼓励您在我们的uservoice网页https://onenote.uservoice.com/forums/245490-onenote-developer-apis中添加一个条目),但您可以用您想要的任何新内容替换整个页面。
Another option is similar to what Manoj suggested - replace the parent of the element you want to delete with the same content minus the element you want to delete. 另一个选项类似于Manoj的建议-用相同的内容减去要删除的元素替换要删除的元素的父元素。
The content parameter on a PATCH API action of type replace is expected to be valid HTML. 类型为PATCH的PATCH API操作上的content参数应该是有效的HTML。 It's not valid to specify whitespace as replacement content.
指定空白作为替换内容是无效的。
You can explore replacing a higher level element than a single paragraph to achieve your scenario, for example. 例如,您可以探索替换比单个段落更高级别的元素来实现您的方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.