jason jason - 1 year ago 62
Python Question

Python Onenote, getting nothing on request

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


Here is my code:

import requests

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:


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.

Answer Source

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

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download