替换操作将打破OneNote(Graph API)中的嵌套列表 [英] Replace operation breaks a nested list in OneNote (Graph API)

查看:80
本文介绍了替换操作将打破OneNote(Graph API)中的嵌套列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

用户在OneNote中将他的待办事项组织为嵌套列表,如下所示:用户页面

我需要将任务A"标记为已完成.根据文档,我应该对待办事项执行替换操作.

首先,我打电话给GET /me/onenote/pages/{pageId}/content?includeIDs=true,找到待办事项任务A"的正确ID(请参阅修补程序之前的页面内容"⇩).

然后我随身发送PATCH /me/onenote/pages/{pageId}/content:

[
  {
    "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响应204,并且任务A"现在已完成.但它已移至第2点"下:更新页面

如果我替换任务B"的标记,则会出现相同的问题-它已完成,但是在子任务B1"下.

如何在不中断列表的情况下替换待办事项?


PATCH(图形API响应)之前的页面内容

<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>

PATCH(图形API响应)后的页面内容

<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>

解决方案

对于此问题,我不知道API服务器端如何处理它.您可以在 UserVoice 中提交功能请求,或在

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.

<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>

这篇关于替换操作将打破OneNote(Graph API)中的嵌套列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆