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.
            Asked
            
        
        
            Active
            
        
            Viewed 506 times
        
    1
            
            
        - 
                    Are you using the OneNote REST API? (http://dev.onenote.com/docs) or the the COM API? – Jorge Aguirre Nov 25 '15 at 19:09
 - 
                    I don't know the OneNote REST API. I have try to insert lines to XML format of OneNote. – iseo Nov 26 '15 at 10:36
 - 
                    If your app works locally you can consider [this comment](http://stackoverflow.com/a/36281473/2609580) – DmitryP Mar 29 '16 at 12:01
 
2 Answers
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
 
- 
                    
 - 
                    This is an HTTP request that can be done in C#. I suggest checking out the windows store sample with the OneNote API – Jorge Aguirre Nov 26 '15 at 22:40
 
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