【发布时间】:2020-01-08 13:05:41
【问题描述】:
由于 DocuSign API 对每个请求的最大大小限制为 25 MB,我们必须将信封创建拆分为多个请求,最初将创建信封作为草稿。然后使用信封文档更新调用将文档更新到同一个信封。
但是,对于我使用多部分请求添加的每个 Word 文档,我们都会收到“FORMAT_CONVERSION_ERROR”错误。 PDF文档可以添加成功
"errorDetails": {
"errorCode": "FORMAT_CONVERSION_ERROR",
"message": "The data could not be converted."
}
是否有变通方法使其适用于多部分请求?
这是我遵循的步骤:
- 我正在第一个 POST API 调用中创建信封(不包含文档)(https://demo.docusign.net/restapi/v2/accounts/{accountid}/envelopes)
- 通过为每个文档调用 PUT API 将文档(pdf 和 docx)添加到信封(多部分方法)(https://demo.docusign.net/restapi/v2/accounts/{accountid}/envelopes/{envelopeId}/documents/{docId})
- 只有 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."
}
【问题讨论】:
-
愚蠢的问题,但您确定将 {ext} 参数设置为
docx以便您的 content-disposition 标头具有fileExtension=docx吗?您可以使用 DocuSign API 日志记录 (support.docusign.com/en/guides/…) 来捕获失败的调用并准确确认您的应用程序发送到 DS API 的内容。 -
嗨 Drew,提供了 docx 的日志详细信息。仅供参考,获取 pdf 文件上传的成功响应。
标签: docusignapi multipart