Reputation: 25
Note: using the same PATCH request as defined in Onenote API (REST) - PATCH append - "must include a 'commands'" error when Commands is already supplied (?!)
Each PATCH request is an append operation, and uses the following layout supplied to |HTML| in my code:
<div>
<h1>Hardcoded_Name_ForNow</h1>
<h3>4.345054</h3>
<p>sdfsdfsdf</p>
<img src="name:image-part-name" alt="New binary image" />
</div>
However, when I GET the content of the page (ref: https://jsapi.apiary.io/apis/onenote/reference/get-pages/v10pagesid/get.html?console=1), it turns out like this:
(HEADER OMITTED)
<body data-absolute-enabled="true" style="font-family:Calibri;font-size:11pt">
<div style="width:624px">
<h1 style="font-size:16pt;color:#1e4e79;margin-top:11pt;margin-bottom:11pt">Hardcoded_Name_ForNow</h1>
<h3 style="font-size:12pt;color:#5b9bd5;margin-top:11pt;margin-bottom:11pt">47.77527</h3>
<p>TEST</p>
<img alt="New binary image" width="624" height="353" src="https://www.onenote.com/api/v1.0/resources/0-60a8d03c70a04372ad60cabb8191f86d!1-6C3CB48828A4FCE7!185/$value" data-src-type="image/png" data-fullres-src="https://www.onenote.com/api/v1.0/resources/0-60a8d03c70a04372ad60cabb8191f86d!1-6C3CB48828A4FCE7!185/$value" data-fullres-src-type="image/png" />
<h1 style="font-size:16pt;color:#1e4e79;margin-top:11pt;margin-bottom:11pt">Hardcoded_Name_ForNow</h1>
<h3 style="font-size:12pt;color:#5b9bd5;margin-top:11pt;margin-bottom:11pt">41.16911</h3>
<p>ewqeqweqweqew</p>
<img alt="New binary image" width="624" height="353" src="https://www.onenote.com/api/v1.0/resources/0-9d9ab7935d16464eb826e70dd7fdb3ef!1-6C3CB48828A4FCE7!185/$value" data-src-type="image/png" data-fullres-src="https://www.onenote.com/api/v1.0/resources/0-9d9ab7935d16464eb826e70dd7fdb3ef!1-6C3CB48828A4FCE7!185/$value" data-fullres-src-type="image/png" />
...
</div>
</body>
I know that if I didn't supply a specific target ID, the PATCH request will target the topmost . However, I expected the PATCH request to throw in the layout wholesale without stripping the encapsulator.
Currently working around it by assuming h1, h3, p, img will always be in order, but this is harder to maintain if the tag order changes or new tags are added.
Enabling div id attributes doesn't help, the are simply not there in the first place.
Upvotes: 1
Views: 169
Reputation: 6606
We don't really have a way to store arbitrary containers in OneNote, so we sort of do our best to resynthesize them on demand. Unless they have some meaningful distinguishing data, individual ones can melt away, as you are seeing. Our aim it to get presentation content in and out of the surface rather than to be a high fidelity HTML store.
So that said, if you add a data-id="UniqueFoo" attribute to your , we treat it as semantically meaningful, so we do extra work to reproduce those semantics. The HTML may not be exactly the same, but we should produce the semantic equivalent as far as containment goes, which will likely in this simple case mean your is preserved as you'd expect.
You could use a guid or some such as the data-id attribute for an easy unique value if there's nothing unique in your app that these divs represent.
Upvotes: 0