Endpoint: POST https://graph.microsoft.com/v1.0/me/onenote/sections/{section-id}/pages
Request header: key:Content-Type value:multipart/form-data; boundary=MyAppPartBoundary
Request Body: --MyAppPartBoundary Content-Disposition: form-data; name="Presentation" Content-Type: text/html
/*<!DOCTYPE html>
<html>
<head>
<title>A page with an image: Image binary data</title>
<meta name="created" value="2015-11-11T12:45:00.000-8:00"/>
</head>
<body>
<p>This page displays the uploaded image.</p>
<img src="name:image-block-name" alt="a cool image" width="500">
</body>
</html>
--MyAppPartBoundary
Content-Disposition: form-data; name="MyAppPictureId" Content-Type: image/jpeg
...9j/4AAQSkZJRgABAQEAYABgAAD/2wBDAAMCAgMCAgMDAwMEAwMEBQ...
--MyAppPartBoundary--*/
Response Preview: { "error": { "code": "20011", "message": "The multi-part payload was malformed.", "innerError": { "date": "2023-11-20T13:59:19", "request-id": "df177375-fe0e-46f4-b871-367fa0d7a144", "client-request-id": "da2ecc33-a170-262b-a124-a688e7025889" } } }
I was trying to update a binary data(base64) of an image but it keep on showing the same error please let me know where iam going the mistake.
I just tried out your code. You need to change
-
-MyAppPartBoundary Content-Disposition: form-data; name="Presentation" Content-Type: text/html
to
and
to
Also make sure you are using CRLF as line returns. Basically the API is really picky about line spacings.