我正在尝试通过Microsoft Graph API使用PATCH
请求更新OneNote页面。我不断收到Error 19999
,根据此https://msdn.microsoft.com/en-us/office/office365/howto/onenote-error-codes表示"未知错误"
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);
我可以验证授权码是否有效(因为我能够执行其他操作,如创建新页面)并具有更新页面所需的范围。任何人都可以帮我解决这个问题吗?
答案 0 :(得分:1)
您的JSON无效。这就是我相信你想要的。
[{
"target": "body",
"action": "append",
"position": "after",
"content": "<div> added new </div>"
}]