0
votes

Using the OneNote API (via PHP and cURL) I can get the data for a shared notebook (not all data shown here):

"id": "1-ff693481-8376-40a5-936a-1d94aaf0acc5",
"self": "https://graph.microsoft.com/v1.0/users/1f1e0d22-2cab-43fa-944f-41ff04441b26/onenote/notebooks/1-ff693481-8376-40a5-936a-1d94aaf0acc5",
"displayName": "Config-003",
"sectionsUrl": "https://graph.microsoft.com/v1.0/users/1f1e0d22-2cab-43fa-944f-41ff04441b26/onenote/notebooks/1-ff693481-8376-40a5-936a-1d94aaf0acc5/sections",
...

But when I use the sectionsUrl to get the sections within that notebook (or use the id to construct my own URL), all I get is a 404 error message:

curl_exec() failed: The requested URL returned error: 404 Not Found

So what's a way of getting the sections (then the pages within them) that works?

Note: Answers to Accessing shared notebooks pages and sections for Onenote for business acoount don't answer my question.

[EDIT] Just to clarify in the light of Martin Zeitler's answer (now deleted): the access token is presented with the sections request, just as for the preceding notebooks request:

CURLOPT_HTTPHEADER => array("Content-Type: text/html", "Authorization: Bearer " . $encodedAccessToken)

1

1 Answers

1
votes

Please use the GET-RecentNotebooks API https://docs.microsoft.com/en-us/graph/api/notebook-getrecentnotebooks?view=graph-rest-1.0 to retrieve shared notebooks. And then for any shared notebook, use the POST-GetNotebookFromWebUrl API https://docs.microsoft.com/en-us/graph/api/notebook-getnotebookfromweburl?view=graph-rest-1.0 to get the correct sections url