我正在尝试使用其余 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/