如何使用Onenote Graph API删除和重命名Notebook名称

时间:2018-04-30 17:11:29

标签: office365 onenote onenote-api

我想重命名笔记本名称。我试过下面的Graph请求。

PATCH "graph.microsoft.com/v1.0/me/onenote/notebooks{id}" 

我得到" UnknownError",什么是PATCH请求网址重命名笔记本?

2 个答案:

答案 0 :(得分:1)

OneNote笔记本在暴露给OneDrive api时是文件夹,可以是renameddeleted

然而,OneDrive文档特别建议不要使用OneNote笔记本执行此操作。

示例PHP代码删除NoteBook(您将通过https://graph.microsoft.com/v1.0/me/drive/root/children获取{item-id})

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,
    'https://graph.microsoft.com/v1.0/me/drive/items/{item-id}');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST => 'DELETE');
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLINFO_HEADER_OUT, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: */*',
    'return-client-request-id: true','Content-Type: application/json',
    'Authorization: Bearer eyJ0eXAiOiJKV1Qi…));
$response = curl_exec($ch);
curl_close($ch);
return $response;

已删除的笔记本将移至回收站。

示例php代码重命名NoteBook

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,
    'https://graph.microsoft.com/v1.0/me/drive/items/{item-id}');
curl_setopt($ch, CURLOPT_CUSTOMREQUEST => 'PATCH');
curl_setopt($ch, CURLOPT_POSTFIELDS,'{"name":"newname"}');  
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLINFO_HEADER_OUT, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Accept: */*',
    'return-client-request-id: true','Content-Type: application/json',
    'Authorization: Bearer eyJ0eXAiOiJKV1Qi…));
$response = curl_exec($ch);
curl_close($ch);
return $response;

答案 1 :(得分:0)

不支持此功能。您可能希望将此添加到我们的uservoice。

https://onenote.uservoice.com/forums/245490-onenote-developer-apis