0

I'm trying to get the pages from my onenote notebook in onedrive. the URL is ...

https://onedrive.live.com/edit.aspx?cid=ab87696357344a7e&page=view&resid=AB87696357344A7E!246&parId=AB87696357344A7E!116&app=OneNote

Here is my code:

import requests
access_token='xxxx'

root='https://www.onenote.com/api/v1.0/me/notes/'
id ='ab87696357344a7e'
url=root + id +'/sections'

headers={"Authorization" : "Bearer " + access_token, 'Accept': 'application/json'}
request=requests.Request(method="GET",headers = headers, url=url)

print request.data
print request.url
print request.json
print request.files

I'm getting nothing, here is the output:

[]
https://www.onenote.com/api/v1.0/me/notes/ab87696357344a7e/sections
None
[]

What am I doing wrong here? is the ID wrong? I didn't know what ID they were talking about.

I've also tried my app ID and it also gets me nothing.

jason
  • 3,811
  • 18
  • 92
  • 147
  • Possible duplicate of [How to Access/Download OneNote notebook with Python?](https://stackoverflow.com/questions/34622471/how-to-access-download-onenote-notebook-with-python) – Laurent LAPORTE May 22 '17 at 20:04
  • @Laurent LAPORTE Your link doesn't help. I just links me to the reference page for onenote developers. This is a very specific question. – jason May 22 '17 at 20:29

1 Answers1

1

Are you getting a 200 OK from the service?

Most likely, you're getting a 404 since the ID you're using for the notebook doesn't exist. The id's for OneDrive and OneNote aren't the same - you should first do a call like

GET https://www.onenote.com/api/v1.0/notebooks

Then given a notebook id from that call's result, to a

GET https://www.onenote.com/api/v1.0/notebooks/id/sections

Jorge Aguirre
  • 2,787
  • 3
  • 20
  • 27
  • I believe the modification that happens is that a 0- gets prepended to the notebook id. However, you shouldn't rely on this and should always get your id's from the API. – Jorge Aguirre May 22 '17 at 22:04