User organizes his todos in OneNote as nested list which looks like this: user's page
I need to mark "Task A" as completed. According to a documentation I should perform replace action for todo.
First I call GET /me/onenote/pages/{pageId}/content?includeIDs=true
to find right id of todo "Task A" (see "Page content before the PATCH" ⇩).
Then I send PATCH /me/onenote/pages/{pageId}/content
with body:
[
{
"action": "replace",
"target": "p:{33109592-eab9-44fa-8cec-867ab11cecfd}{55}",
"content": "<p data-tag=\"to-do:completed\" style=\"margin-top:0pt;margin-bottom:0pt\">Task A</p>"
}
]
API responds 204, and "Task A" is completed now. But it has been moved under "Point 2": updated page
The same problem appears if I replace tag for "Task B" - it becomes completed but goes under "Subtask B1".
How can I replace a todo without breaking a list?
Page content before the PATCH (Graph API response)
<html lang="en-US">
<head>
<title>Nested list</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="created" content="2018-10-04T09:46:00.0000000" />
</head>
<body data-absolute-enabled="true" style="font-family:Calibri;font-size:11pt">
<div id="div:{33109592-eab9-44fa-8cec-867ab11cecfd}{49}" style="position:absolute;left:76px;top:144px;width:548px">
<p id="p:{33109592-eab9-44fa-8cec-867ab11cecfd}{55}" data-tag="to-do" style="margin-top:0pt;margin-bottom:0pt">Task A</p>
<p id="p:{33109592-eab9-44fa-8cec-867ab11cecfd}{52}" style="margin-top:0pt;margin-bottom:0pt">Point 1</p>
<p id="p:{33109592-eab9-44fa-8cec-867ab11cecfd}{54}" style="margin-top:0pt;margin-bottom:0pt">Point 2</p>
<p id="p:{33109592-eab9-44fa-8cec-867ab11cecfd}{59}" data-tag="to-do" style="margin-top:0pt;margin-bottom:0pt">Task B</p>
<p id="p:{33109592-eab9-44fa-8cec-867ab11cecfd}{58}" data-tag="to-do" style="margin-top:0pt;margin-bottom:0pt">Subtask B1</p>
</div>
</body>
</html>
Page content after the PATCH (Graph API response)
<html lang="en-US">
<head>
<title>Nested list</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="created" content="2018-10-04T09:46:00.0000000" />
</head>
<body data-absolute-enabled="true" style="font-family:Calibri;font-size:11pt">
<div id="div:{33109592-eab9-44fa-8cec-867ab11cecfd}{49}" style="position:absolute;left:76px;top:144px;width:548px">
<p id="p:{33109592-eab9-44fa-8cec-867ab11cecfd}{52}" style="margin-top:0pt;margin-bottom:0pt">Point 1</p>
<p id="p:{33109592-eab9-44fa-8cec-867ab11cecfd}{54}" style="margin-top:0pt;margin-bottom:0pt">Point 2</p>
<p id="p:{b815e00e-3326-49db-bcdd-7aecba36b1a4}{92}" data-tag="to-do:completed" style="margin-top:0pt;margin-bottom:0pt">Task A</p>
<p id="p:{33109592-eab9-44fa-8cec-867ab11cecfd}{59}" data-tag="to-do" style="margin-top:0pt;margin-bottom:0pt">Task B</p>
<p id="p:{33109592-eab9-44fa-8cec-867ab11cecfd}{58}" data-tag="to-do" style="margin-top:0pt;margin-bottom:0pt">Subtask B1</p>
</div>
</body>
</html>
For this question, I don't know how the API server side handle it. You can submit an feature request in the UserVoice or submit an bug in Github.
A workaround for you on client side: add on emtpy line between the Task A and Point1. I Have test it, it works well on my side.