1

我可以使用下面的代码在一个部分中创建一个页面,我可以使用 APIGee 控制台应用程序在 OneNote OneDrive 中创建一个笔记本,但我不知道如何在 OneNote 客户端程序中创建一个新的笔记本。下面是我在 Foo 部分中创建页面的代码片段。

如何修改此代码以在客户端中创建新笔记本?

private static readonly Uri PagesEndPoint = new Uri("https://www.onenote.com/api/v1.0/pages?sectionName=Foo");

                HttpResponseMessage response;
            using (var imageContent = new StreamContent(await GetBinaryStream("assets\\SOAP.jpg")))
            {
                imageContent.Headers.ContentType = new MediaTypeHeaderValue("image/jpeg");
                HttpRequestMessage createMessage = new HttpRequestMessage(HttpMethod.Post, PagesEndPoint)
                {
                    Content = new MultipartFormDataContent
                    {
                        {new StringContent(simpleHtml, System.Text.Encoding.UTF8, "text/html"), "Presentation"},{imageContent, imagePartName}
                    }
                };


                // Must send the request within the using block, or the image stream will have been disposed.
                response = await client.SendAsync(createMessage);
            }

            tbResponse.Text = response.ToString();
            return await TranslateResponse(response);
4

2 回答 2

2

如果 create notebook API 调用返回成功(201),则表示已在用户的 OneDrive 上成功创建 notebook。但是,笔记本不会自动显示在用户的 OneNote 客户端中。用户需要在 OneNote 客户端应用程序之一中打开新创建的笔记本。

或者,您可以使用 API 响应消息中的links.oneNoteClientUrl.href属性在 OneNote 客户端中为用户打开笔记本。

希望有帮助。

谢谢,詹姆斯

于 2014-08-04T17:33:20.240 回答
1

如果您安装了 OneNote,则可以使用 OneNote COM API。您可以在此处修改 VanillaAddin:https ://github.com/OneNoteDev/VanillaAddIn

此外,您可以使用相同的 COM API 编写控制台应用程序来执行此操作(因此您无需编写 COM 插件)。

于 2016-03-16T23:29:48.627 回答