i want to update an OneNote page with MS Graph but i get the following error:
{
"error": {
"code": "20109",
"message": "The request's JSON was invalid or could not be parsed.",
"innerError": {
"date": "2020-11-17T07:22:13",
"request-id": "a5d97ae9-d792-4e7e-8b98-3ff450916905",
"client-request-id": "a5d97ae9-d792-4e7e-8b98-3ff450916905"
}
}
}
My code:
dest = f'https://graph.microsoft.com/v1.0/me/onenote/pages/{page_id}/content'
payload = {
'target': 'body',
'action': 'prepend',
'content': '<p>New paragraph as first child in the first div</p>'
}
print(page_id)
print(json.dumps(payload))
print(app.session.get(app.ACCESS_TOKEN))
headers = {'Authorization': 'Bearer ' + app.session.get(app.ACCESS_TOKEN), 'Content-Type': 'application/json'}
result = requests.patch(dest, json.dumps(payload), headers=headers)
print(result.text)
I've already tried:
result = requests.patch(dest, data=json.dumps(payload), headers=headers)
result = requests.patch(dest, json=json.dumps(payload), headers=headers)
result = requests.patch(dest, json=payload, headers=headers)