错误“请求太大 (413)"尝试将 PDF 文件上传到 OneNote 时

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

本文介绍了错误“请求太大 (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 操作会成功处理小于约 4MB 的 PDF 文件.但是,对超过 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

微软在 Graph 和 OneNote 的文档:

  • POST 总大小限制约为 70 MB,包括图像、文件和其他数据.实际限制受下游编码的影响,因此没有固定的字节数限制.超出限制的请求可能会产生不可靠的结果.
  • 每个数据部分的大小限制为 25 MB,包括部分标头.Microsoft Graph 拒绝超出限制的数据部分.

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

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 是 OneNote REST API.文档中提到的限制在 OneNote API 方面是准确的,但由于此请求由 Graph 处理,因此在该请求被路由到底层 API 之前,您将达到 Graph 本身的较小的 4 MB 限制.

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 时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本文标题为:错误“请求太大 (413)"尝试将 PDF 文件上传到 OneNote 时

基础教程推荐