OneNote update page

211 views Asked by At

Now I'm trying to use Microsoft graph ontnote update page, the operation of the API to update the page. But I met a problem When call update interface to upload pictures is not correct

PATCH https://www.onenote.com/api/v1.0/me/notes/pages/{page-id}/content

Content-Type: multipart/form-data; boundary=PartBoundary123 Authorization: Bearer {token}

--PartBoundary123 Content-Disposition: form-data; name="Commands" Content-Type: application/json

[ { 'target':'body', 'action':'append', 'content':'' } ]

--PartBoundary123 Content-Disposition: form-data; name="image-part-name" Content-Type: image/png

... binary image data ...

--PartBoundary123--

response:The multi-part payload was malformed.

2

There are 2 answers

0
codeye On

Hi
This may not be the answer but it's worth making sure your script is using windows line breaks (CR+LF). The page APIs are very sensitive about this and it always catches me out on a Linux based system.

1
Bill Petrakos On

Curious if the line breaks were the issue for the multipart payload being malformed?

There is one other problem with the request you have posted. In your commands JSON, the content should not be empty. It should look something like this:

[{'target':'body','action':'append','content':''}]

Otherwise you'll get an error 400 Bad Request with message=The PATCH argument $content: is invalid.