How to Delete and Rename Notebook name Using Oneno

2019-08-23 04:01发布

问题:

I want to rename notebook name. i tried below Graph request.

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

I am getting "UnknownError", What is PATCH Request url to rename notebook?

回答1:

OneNote Notebooks are folders when exposed to the OneDrive api and can be renamed or deleted.

The OneDrive documentation, however, specifically suggests not doing this with OneNote Notebooks.

sample php code to delete NoteBook (you would obtain {item-id} via https://graph.microsoft.com/v1.0/me/drive/root/children)

$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;

The deleted Notebook is moved to the Recycle bin.

sample php code to rename 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;


回答2:

This is not supported. You might want to add this to our uservoice.

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