1
votes

I have an OneNote page with table of tasks: First column is a task name with to-do tag (checkbox), and second column with description. The table has been created from OneNote web UI (OneNote online).

I want to mark tasks completed via Graph API. According documentation I can update table content only by replacing whole table. But after update my table does not have borders anymore, and all to-do tags (checkboxes) are missing.

Workflow:

  1. Get page content (docs, response)
  2. Take table from content, find required task, replace data-tag from to-do to to-do:completed
  3. Get page content with generated IDs (docs, response) to find target table id
  4. Send PATCH request to replace the table (request - response)
  5. Table became replaced but all border has been set to 0px, and all data-tags has been removed

Here is a formatted value of content field of PATCH request payload (raw request here):

<table style="border:1px solid;border-collapse:collapse">
    <tr>
        <td style="border:1px solid"><span style="font-weight:bold">Task</span></td>
        <td style="border:1px solid"><span style="font-weight:bold">Comment</span></td>
    </tr>
    <tr>
        <td style="border:1px solid"><span data-tag="to-do:completed">Update todo in table</span></td>
        <td style="border:1px solid">There are some issues when we updating todos located inside of tables</td>
    </tr>
</table>

What is wrong with my PATCH request?

2

2 Answers

3
votes

Do not specify border in the style attribute. Just specify the border as the table cell attribute.

And thanks for using the OneNote APIs via Microsoft Graph!

1
votes


From this link at the bottom the Example block of HTML has info about how the OneNote-API handles tables.
Specifically borders will be hidden or displayed depending on the current setting for the page under "Table Tools" -> "Layout" -> "Hide Borders" toggle.
In terms of to-do boxes these have to be wrapped in a paragraph, for example:

 <td><p data-tag="to-do:completed" data-id="oa">OA Check</p></td>