Microsoft graph api 错误的请求错误400毫秒图形OneNote API
我得到以下错误:Microsoft graph api 错误的请求错误400毫秒图形OneNote API,microsoft-graph-api,onenote-api,Microsoft Graph Api,Onenote Api,我得到以下错误: { StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.StreamContent, Headers: { client-request-id: 09bcf6bf-1c4a-4f9d-9713-42dfbed17ecd
{
StatusCode: 400,
ReasonPhrase: 'Bad Request',
Version: 1.1,
Content: System.Net.Http.StreamContent,
Headers:
{
client-request-id: 09bcf6bf-1c4a-4f9d-9713-42dfbed17ecd
request-id: 09bcf6bf-1c4a-4f9d-9713-42dfbed17ecd
Transfer-Encoding: chunked
x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"South Central US","Slice":"SliceB","ScaleUnit":"002","Host":"AGSFE_IN_3","ADSiteName":"SAN"}}
Duration: 395.8064
Cache-Control: private
Date: Tue, 26 Sep 2017 17:28:22 GMT
Content-Type: application/json
}
}
当我使用此代码在笔记本中创建新分区时:
///创建一个以患者姓名作为显示名的新分区
tempSectionName=LastNameEdit.Text.ToString()+“”+FirstNameEdit.Text.ToString();
字符串url=”https://graph.microsoft.com/v1.0/me/onenote/";
CreateSectionInNotebook(Globals.CurrentEMRNotebookID、tempSectionName、url);
}
///
///在给定notebookId下创建具有给定名称的节
///
///父笔记本的Id
///要创建的节的名称
///
///使用application/json内容类型创建节
私有异步void CreateSectionInNotebook(字符串notebookId、字符串sectionName、字符串apiRoute)
{
var client=新的HttpClient();
//注意:API只支持JSON响应。
client.DefaultRequestHeaders.Accept.Add(新的MediaTypeWithQualityHeaderValue(“应用程序/json”);
//不添加身份验证标头将产生未经授权的调用,API将返回401
client.DefaultRequestHeaders.Authorization=新的AuthenticationHeaderValue(“Bearer”,authResult.AccessToken);
//准备对节终结点的HTTP POST请求
//请求正文内容类型为application/json,需要name属性
var createMessage=new-HttpRequestMessage(HttpMethod.Post,apiRoute+@“notebooks/”+notebookId+“/sections”)
{
Content=newstringcontent(“{name:'”+WebUtility.UrlEncode(sectionName)+“}”,Encoding.UTF8,“application/json”)
};
HttpResponseMessage response=等待客户端.SendAsync(createMessage);
}
我已尝试匹配来自的输入,但它使用OneNote API
如果Microsoft Graph Explorer扩展了OneNote API的
APIgee
等MSGraph
/OneNote
功能,那就太好了 Microsoft Graph的有效负载与OneNote API略有不同
在这种情况下,您需要设置“displayName”而不是“name”
以下是Microsoft Graph文档供将来参考:Microsoft Graph的有效负载与OneNote API略有不同 在这种情况下,您需要设置“displayName”而不是“name”
以下是Microsoft Graph文档供将来参考:MS Graph explorer确实有OneNote示例-在左侧查找。MS Graph explorer确实有OneNote示例-在左侧查找