首页 > 解决方案 > 使用多部分将 Word 文档添加到现有信封时出现 FORMAT_CONVERSION_ERROR

问题描述

由于 DocuSign API 对每个请求的最大大小限制为 25 MB,我们必须将信封创建拆分为多个请求,最初信封将创建为草稿。然后将使用信封文档更新调用将文档更新到相同的信封。

但是,对于我使用多部分请求添加的每个 Word 文档,我们都会收到“FORMAT_CONVERSION_ERROR”错误。PDF文档可以成功添加

 "errorDetails": {
        "errorCode": "FORMAT_CONVERSION_ERROR",
        "message": "The data could not be converted."
      }

是否有解决方法使其适用于多部分请求?

以下是我遵循的步骤:

  1. 我在第一个 POST API 调用中创建信封(没有文档)(https://demo.docusign.net/restapi/v2/accounts/ {accountid}/envelopes)
  2. 通过为每个文档调用 PUT API 将文档(pdf 和 docx)添加到信封(多部分方法)(https://demo.docusign.net/restapi/v2/accounts/ {accountid}/envelopes/{envelopeId}/文件/{docId})
  3. 仅将 PDF 文件上传到 docusign,而 docx 类型文件上传时出现 400 错误“FORMAT_CONVERSION_ERROR - 数据无法转换”错误

我正在添加这个标题"Content-Disposition", "file; filename={filename};fileExtension={ext};documentId={id}"

任何建议/解决方案将不胜感激。

日志详细信息:

PUT https://demo.docusign.net:7801/restapi/v2/accounts/{myaccountid}/envelopes/{myenvelopeid}/documents/1

TraceToken: d0d9eae1-01d3-4c56-928d-da38a7ac30fc
Timestamp: 2020-01-09T08:48:52.7616114Z

Content-Type: multipart/form-data; boundary=LV-qEHBRJq6zprmD52mUZfeNsrT5alHGfkE8w
Content-Disposition: file; filename=MyTemplate.docx; fileExtension=docx; documentId=1
Content-Length: 12998
Connection: Keep-Alive
Transfer-Encoding: chunked
Authorization: bearer [omitted]
Expect: 100-continue
Host: demo.docusign.net
User-Agent: Apache-HttpClient/4.0.3(java 1.5)
X-SecurityProtocol-Version: TLSv1.2
X-SecurityProtocol-CipherSuite: ECDHE-RSA-AES256-GCM-SHA384
x-forwarded-for: 106.51.84.53

--LV-qEHBRJq6zprmD52mUZfeNsrT5alHGfkE8w
Content-Disposition: form-data; name="MyTemplate.docx"; filename="MyTemplate.docx"
Content-Type: application/octet-stream
Content-Transfer-Encoding: binary

//Some binary data here.

--LV-qEHBRJq6zprmD52mUZfeNsrT5alHGfkE8w--

400 BadRequest
Content-Type: application/json; charset=utf-8
Content-Length: 96
X-DocuSign-TraceToken: d0d9eae1-01d3-4c56-928d-da38a7ac30fc

{
  "errorCode": "FORMAT_CONVERSION_ERROR",
  "message": "The data could not be converted."
}

标签: docusignapimultipart

解决方案


您可以将信封的多部分 mime 编码与 BASE64 编码或以二进制格式发送的单个文件一起使用。

检查您使用的是二进制格式,并且对 DocuSign 的整个请求不超过 25 MB。

下载并运行您喜欢的语言的 eg-03-example 软件存储库版本。这些存储库存储在 github.com/docusign 中,它们在此处记录:https ://developers.docusign.com/esign-rest-api/code-examples/code-example-send-binary 。

在示例代码中,工作流 #10 显示了如何以二进制模式发送。该示例发送一个 Word 文档,因此您可以替换自己的文档以检查它是否正常工作。


推荐阅读