尝试使用Graph API直接创建页面,这是正确的方法/可行的方法,否则我们应该仅使用HttpClient创建页面。
我也看不到在请求下创建页面的C#代码示例, https://docs.microsoft.com/en-us/graph/api/section-post-pages?view=graph-rest-1.0#request
错误
InvalidOperationException:此流不支持超时。 System.IO.Stream.get_ReadTimeout() JsonSerializationException:从“ System.IO.MemoryStream”上的“ ReadTimeout”获取值时出错。 Newtonsoft.Json.Serialization.ExpressionValueProvider.GetValue(对象目标)
代码
var page = new OnenotePage
{
Title = "Graph API Notes Page",
Content = new MemoryStream(Encoding.UTF8.GetBytes("Created Date - " + DateTime.Now))
};
await graphClient
.Sites[siteId]
.Onenote
.Sections[sectionId]
.Pages
.Request()
.AddAsync(page);
答案 0 :(得分:0)
您可以使用以下代码将内容添加到OneNote页面
string notesContent = $"<!DOCTYPE html><html><head><title>{NotebookTitle}</title></head><body>{NotebookContent}</body></html>";
return await GraphClient.Me.Onenote.Sections[SectionId].Pages.Request().AddAsync(notesContent, "text/html");