1

I want to add lines into a onenote page using C#. To make a page is known, but I cannot find to insert lines at existed onenote page.

iseo
  • 11
  • 2

2 Answers2

0

I'm assuming you're talking about the OneNote REST API. To add lines of text to an existing page in OneNote, you can use the PATCH API. Here's a link to the official docs: http://dev.onenote.com/docs#/reference/patch-pages

Your request should look something like this:

PATCH ~/me/notes/pages/{PAGEID}
Content-Type: application/json
Body:
[
{
   "target":"body",
   "action":"append",
   "position":"after",
   "content":"MySentenceHtmlContent"
}
]

Let me know if you have any questions! Jorge

Jorge Aguirre
  • 2,787
  • 3
  • 20
  • 27
0

I have one solution for inserting text line at an existing OneNote page. With XML format, listing as follows

    public static string SetPageContent(string pageId, string msg)
    {
        string xml;
        onenoteApp.GetPageContent(pageId, out xml, PageInfo.piAll);
        var doc = XDocument.Parse(xml);

        // make newline with msg input
        XElement text = new XElement(ns + "OE",
            new XElement(ns + "T",
                new XCData(msg)));

        // insert new line
        doc.Root.Element(ns + "Outline").Element(ns + "OEChildren").Add(text);

        // Now update the page content
        onenoteApp.UpdatePageContent(doc.ToString());

        return null;
    }
iseo
  • 11
  • 2