错误“请求太大(413)".尝试将PDF文件上传到OneNote时 [英] Error "request too large (413)" when trying to upload a PDF file to OneNote

查看:419
本文介绍了错误“请求太大(413)".尝试将PDF文件上传到OneNote时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Microsoft Graph REST API(Objective-C)在OneNote中创建新页面.这些新页面应包含PDF文档作为附件.

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.

POST操作成功后,PDF文件小于4MB.但是,超过4MB的文件操作失败,并显示错误消息request too large (413)和以下响应:

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

使用的终点是:https://graph.microsoft.com/v1.0/me/onenote/sections/XXX/pages

Microsoft在

Microsoft states in the documentation for Graph and OneNote:

  • POST的总大小限制为〜70 MB,其中包括图像,文件和其他数据.实际限制受下游编码的影响,因此没有固定的字节数限制.超出限制的请求可能会产生不可靠的结果.
  • 每个数据部分(包括部分标题)的限制为25 MB.超出限制的数据部分将被Microsoft Graph拒绝.
  • 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.

我在OneNote的Microsoft Graph文档中找不到POST请求的4MB限制.我当前的问题有什么解决方法吗?

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?

推荐答案

简短的答案是此文档不正确.较长的答案需要对Graph本身有一点了解.

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

Graph是一个API聚合器.它接收传入的请求,将它们路由到一个或多个基础API,然后对响应进行规范化,以便最终开发人员在端点之间获得一致的结果.

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.

在这种情况下,基础API是

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.

当原始文档移植到Graph时,很可能无意中遗漏了文档错误.我已提交了文档问题,因此可以对其进行更正.

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.

这篇关于错误“请求太大(413)".尝试将PDF文件上传到OneNote时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆