error: The multi-part payload was malformed

21 views Asked by At
~~~~
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:

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

--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

... (base64 encoded image data)...

--MyAppPartBoundary--
~~~~

Response Preview:
{
    "error": {
        "code": "20011",
        "message": "The multi-part payload was malformed.",
        "innerError": {
            "date": "2023-11-21T05:21:30",
            "request-id": "56fdbe9f-3fdb-40da-a707-e203172305c6",
            "client-request-id": "9fa896cc-dddc-0bb3-2fcc-bd5fc5b24f7c"
        }
    }
}

I tried to add binary data of an image to onenote page content using Microsoft graph API but ended up getting this error. Please let me know where I've done the mistake.

0

There are 0 answers