jason
jason

Reputation: 4439

Python Onenote, getting nothing on request

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.

Upvotes: 0

Views: 980

Answers (1)

Jorge Aguirre
Jorge Aguirre

Reputation: 2857

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

Upvotes: 1

Related Questions