使用 Graph API 更新 OneNote 页面
Update a OneNote page using Graph API
我正在尝试通过 Microsoft Graph API 使用 PATCH
请求更新 OneNote 页面。我不断得到 Error 19999
根据这个 https://msdn.microsoft.com/en-us/office/office365/howto/onenote-error-codes 意味着 "Unknown Error"
var pageId = settings.DefaultPage;
string requestUrl = $"https://graph.microsoft.com/v1.0/me/onenote/pages/{pageId}/content";
string body = @"{
{
'target':'body',
'action':'append',
'position':'after',
'content':'<div> added new </div>'}}";
var content = new StringContent(body, Encoding.UTF8, "application/json");
HttpRequestMessage req = new HttpRequestMessage()
{
Method = new HttpMethod("PATCH"),
Content = content,
RequestUri = new Uri(requestUrl)
};
HttpClient client = new HttpClient()
{
BaseAddress = new Uri(requestUrl),
};
client.DefaultRequestHeaders.TryAddWithoutValidation("authorization", "Bearer " + settings.MsaAccessCode);
HttpResponseMessage response = await client.SendAsync(req);
我可以验证授权码是否有效(因为我可以执行其他操作,例如创建新页面)并且具有更新页面所需的范围。谁能帮我找出这里的问题?
您的JSON无效。这就是我相信你想要的。
[{
"target": "body",
"action": "append",
"position": "after",
"content": "<div> added new </div>"
}]
我正在尝试通过 Microsoft Graph API 使用 PATCH
请求更新 OneNote 页面。我不断得到 Error 19999
根据这个 https://msdn.microsoft.com/en-us/office/office365/howto/onenote-error-codes 意味着 "Unknown Error"
var pageId = settings.DefaultPage;
string requestUrl = $"https://graph.microsoft.com/v1.0/me/onenote/pages/{pageId}/content";
string body = @"{
{
'target':'body',
'action':'append',
'position':'after',
'content':'<div> added new </div>'}}";
var content = new StringContent(body, Encoding.UTF8, "application/json");
HttpRequestMessage req = new HttpRequestMessage()
{
Method = new HttpMethod("PATCH"),
Content = content,
RequestUri = new Uri(requestUrl)
};
HttpClient client = new HttpClient()
{
BaseAddress = new Uri(requestUrl),
};
client.DefaultRequestHeaders.TryAddWithoutValidation("authorization", "Bearer " + settings.MsaAccessCode);
HttpResponseMessage response = await client.SendAsync(req);
我可以验证授权码是否有效(因为我可以执行其他操作,例如创建新页面)并且具有更新页面所需的范围。谁能帮我找出这里的问题?
您的JSON无效。这就是我相信你想要的。
[{
"target": "body",
"action": "append",
"position": "after",
"content": "<div> added new </div>"
}]