【问题标题】:Create OneNote (client) Notebook with OneNote API使用 OneNote API 创建 OneNote(客户端)笔记本
【发布时间】:2016-03-17 07:29:48
【问题描述】:

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

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

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

【问题讨论】:

    标签: onenote


    【解决方案1】:

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

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

    希望对您有所帮助。

    谢谢, 詹姆斯

    【讨论】:

    • 谢谢詹姆斯,希望看到更直接的方法。
    【解决方案2】:

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多