OneNote API - no HTTP Resource found?

2019-09-09 06:34发布

问题:

I'm calling this endpoint https://graph.microsoft.com/beta/me/notes/, and while the right user id was fetched, the below error occurs... Not sure what's going on at all, as this error is not documented:

{
error: {
code: "UnknownError",
message: "{ "Message": "No HTTP resource was found that matches the request URI 'https://www.onenote.com/api/beta/users('b2909c67-ab0e-45cf-a823-b0f945c22c00')/notes'." }",
innerError: {
request-id: "01b7d80f-aa04-463a-be58-c5a12414e243",
date: "2016-02-27T07:07:06"
}
}
}

--

When trying notebooks/ apparently my OAuth token doesn't have the scope - however it seems that the oauth token registration does not include notes?

{
error: {
code: "40004",
message: "The OAuth token provided does not have the necessary scopes to complete the request. Please make sure you are including one of the following scopes: Notes.ReadWrite.All,Notes.Read.All",
innerError: {
request-id: "73202234-970e-42c8-a569-eca4266ae75a",
date: "2016-03-01T01:49:32"
}
}
}

回答1:

This 404-NotFound status code is expected since https://graph.microsoft.com/beta/me/notes is an incomplete uri. It is the entry point for accessing all OneNote resources but the uri is missing the rest of the path (to specify which resource to get).

for e.g. call https://graph.microsoft.com/beta/me/notes/notebooks to get the list of notebooks. Or https://graph.microsoft.com/beta/me/notes/pages to get a list of pages etc.



回答2:

you need more than just "/notes" - try "/notes/notebooks" for example.



回答3:

I was having the same problem before. I was querying my personal hotmail account for onenote notebooks https://graph.microsoft.com/beta/me/notes/notebooks and was getting no resource found. Then I used my work account to login and found that it worked. For some reason the graph api queries everything except OneNote when the personal account is used. No problems will come up with the work or organisation account.