Replace operation breaks a nested list in OneNote

2019-07-20 13:22发布

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>

1条回答
一纸荒年 Trace。
2楼-- · 2019-07-20 14:07

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.

<div id="div:{46b62548-ca53-41b9-90e1-75d14bbc7504}{38}" style="position:absolute;left:48px;top:115px;width:624px">
            <p id="p:{6a8603ba-4743-4f74-a61a-795245aa36b0}{139}" style="margin-top:0pt;margin-bottom:0pt">  </p>
            <p id="p:{6a8603ba-4743-4f74-a61a-795245aa36b0}{137}" style="margin-top:0pt;margin-bottom:0pt">      </p>
            <p id="p:{9c90b33e-de52-4fe5-9ebe-a6f0787cc91b}{131}" data-tag="to-do:completed" style="margin-top:0pt;margin-bottom:0pt">Task A</p>
            <br />
            <p id="p:{6a8603ba-4743-4f74-a61a-795245aa36b0}{211}" style="margin-top:0pt;margin-bottom:0pt">Point </p>
            <p id="p:{6a8603ba-4743-4f74-a61a-795245aa36b0}{141}" style="margin-top:0pt;margin-bottom:0pt">            Point2</p>
            <p id="p:{6a8603ba-4743-4f74-a61a-795245aa36b0}{169}" style="margin-top:0pt;margin-bottom:0pt">  </p>
            <p id="p:{6a8603ba-4743-4f74-a61a-795245aa36b0}{145}" data-tag="to-do" style="margin-top:0pt;margin-bottom:0pt">Task B</p>
            <p id="p:{6a8603ba-4743-4f74-a61a-795245aa36b0}{173}" style="margin-top:0pt;margin-bottom:0pt">  </p>
            <p id="p:{6a8603ba-4743-4f74-a61a-795245aa36b0}{144}" data-tag="to-do" style="margin-top:0pt;margin-bottom:0pt">      SubTask B1</p>
        </div>
查看更多
登录 后发表回答