I am trying to figure out how to update my page - I need to replace everything inside a <body> tag always.
OneNote API says:
The following elements do not support any PATCH actions: - img or object (absolutely positioned) - meta, head - tr, tda, span, any style tags
Note: Absolutely positioned div, img, or object elements are direct children of the page body that define style=position:absolute.
Ok, that's clear. So I can't replace the <object> that does not have an ID, because if it doesn't it either should be part of <div> with id or it belongs to topmost div.
Here is my page's content:
<html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
<head>
<title>image and PDF 2</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body data-absolute-enabled="true" style="font-family:Calibri;font-size:11pt">
<div id="div:{cfaf2831-c9e3-4b68-99ac-c4fc0bac0937}{32}" data-id="_default" style="position:absolute;left:48px;top:120px;width:624px">
<p id="p:{cfaf2831-c9e3-4b68-99ac-c4fc0bac0937}{38}" style="margin-top:2.8pt;margin-bottom:2.8pt"> SOME TEXT HERE <br />
</p>
<object data-attachment="pdf-sample.pdf" type="application/pdf" data="https://www.onenote.com/api/v1.0/me/notes/resources/0-3329938c15524891836ef46f570c17ce!1-6481EB8A1188E91C!389/$value" />
<img id="img:{cfaf2831-c9e3-4b68-99ac-c4fc0bac0937}{42}" alt="Image" src="https://www.onenote.com/api/v1.0/me/notes/resources/0-dfd3e39146d4425b974a71479787845f!1-6481EB8A1188E91C!389/$value" data-src-type="image/jpeg" data-fullres-src="https://www.onenote.com/api/v1.0/me/notes/resources/0-dfd3e39146d4425b974a71479787845f!1-6481EB8A1188E91C!389/$value" data-fullres-src-type="image/jpeg" />
<object data-attachment="_SaferoomTestDOC.doc" type="application/msword" data="https://www.onenote.com/api/v1.0/me/notes/resources/0-07e77c13690247e88afcd20af3b45a12!1-6481EB8A1188E91C!389/$value" />
</div>
</body>
</html>
Now if I want to replace the image above (<img>) I do like this:
{
'target':'img:{cfaf2831-c9e3-4b68-99ac-c4fc0bac0937}{42}',
'action':'replace',
'content':'<img src="NEW IMAGE" alt="NEW IMAGE" />'
},
But how do I replace the object which in my case is a PDF or Word document?
And how do I replace the whole <body>?
P.S. I've tried wrapping <object> object tags into divs, the <div> tags are stripped on upload.
P.P.S. I always need to replace the whole content inside the body and all the objects and images.