Error “request too large (413)” when trying to upload a PDF file to OneNote

谁说胖子不能爱 提交于 2019-12-08 04:13:59

问题


I'm trying to create new pages in OneNote using Microsoft Graph REST API (Objective-C). Those new pages should contain a PDF document as an attachment.

The POST operations succeed with PDF files that are under ~4MB. However, the operations for files that are over 4MB fail with the error message request too large (413) and the following response:

{
  "error": {
    "code": "BadRequest",
    "message": "Maximum request length exceeded.",
    "innerError": {
      "request-id": "269c663c-9289-47cc-a833-d471b7b867f6",
      "date": "2019-04-09T09:35:49"
    }
  }
}

The end point that is used is: https://graph.microsoft.com/v1.0/me/onenote/sections/XXX/pages


Microsoft states in the documentation for Graph and OneNote:

  • The total POST size limit is ~70 MB, including images, files, and other data. The actual limit is affected by downstream encoding, so there's no fixed byte-count limit. Requests that exceed the limit may produce unreliable results.
  • The limit for each data part is 25 MB, including the part headers. Data parts that exceed the limit are rejected by Microsoft Graph.

I could not find any limit of 4MB for POST requests in the Microsoft Graph documentation for OneNote. Is there any workaround for my current issue?


回答1:


The short answer is that this documentation is incorrect. The longer answer requires a little background on Graph itself.

Graph is an API aggregator. It takes incoming requests, routes them to one or more underlying APIs, and then normalizes the responses so the end developer gets consistent results across endpoints.

In this case, the underlying API is the OneNote REST API. The limits mentioned in the docs are accurate in terms of the OneNote API but since this request is being handled by Graph, you are hitting the smaller 4 MB limit of Graph itself before that request ever gets routed to the underlying API.

More than likely the documentation error was unintentionally missed when the original docs were ported over to Graph. I've filed a documentation issue so it can be corrected.



来源:https://stackoverflow.com/questions/55592242/error-request-too-large-413-when-trying-to-upload-a-pdf-file-to-onenote

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!