docusignapi - 无法使用 DocuSign REST API 上传 WORD 文档

标签 docusignapi

我正在尝试使用其余 API 上传 WORD 文档 (*.doc) 使用以下代码进行记录。但是抛出异常 - UNABLE_TO_LOAD_DOCUMENT,文档损坏。如果我使用我的开发帐户直接从 docusign 网站上传相同的文档,它会正确上传,没有任何错误。任何人都可以帮我找出下面的代码有什么问题。 ( 以下代码适用于 .PDF 格式文件 )

byte[] fileBytes = File.ReadAllBytes(pathOfTheWordDocFile);
EnvelopeDefinition envDef = new EnvelopeDefinition();
envDef.EmailSubject = "[DocuSign C# SDK] - Please sign this doc";

// Add a document to the envelope
Document doc = new Document();
doc.DocumentBase64 = System.Convert.ToBase64String(fileBytes);
doc.Name = Path.GetFileName(strPath);
doc.DocumentId = "1";

envDef.Documents = new List<DocuSignModel.Document>();
envDef.Documents.Add(doc);

最佳答案

默认文档 content-type设置为 application/pdf .要使用不同的 MIME 类型,您只需使用以下命令设置文件扩展名

doc.FileExtension = "docx";

尝试将该行添加到您的代码中,它应该可以工作,如下所示:
byte[] fileBytes = File.ReadAllBytes(pathOfTheWordDocFile);
EnvelopeDefinition envDef = new EnvelopeDefinition();
envDef.EmailSubject = "[DocuSign C# SDK] - Please sign this doc";

// Add a document to the envelope
Document doc = new Document();
doc.DocumentBase64 = System.Convert.ToBase64String(fileBytes);
doc.Name = Path.GetFileName(strPath);
doc.DocumentId = "1";
doc.FileExtension = "docx";

envDef.Documents = new List<DocuSignModel.Document>();
envDef.Documents.Add(doc);

关于docusignapi - 无法使用 DocuSign REST API 上传 WORD 文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36569088/

相关文章:

docusignapi - DocuSign 复合模板的 <PDFBytes> 中包含哪些类型的数据?

docusignapi - Docusign - 用于重新激活已关闭用户的 API

php - fatal error : Uncaught exception 'DocuSign\eSign\ApiException' with message '[401] when trying to go live

node.js - 重定向 URI 未正确注册到 DocuSign

delphi - DocuSign API - 如何在用户认证后获得回调响应?

oauth - 如何在 SPA 中实现 Docusign 而无需最终用户使用 DocuSign 进行身份验证

.net - 电子签名/电子签名 API 建议

jwt - DocuSign - 来自 JWT 配置的签名部分

java - DocuSign Connect webhook 调用不包含 HMAC header x-docusign-signature

java - 使用 docusign api 创建信封,错误 : Object moved