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

Unable to upload WORD Document using DocuSign REST API

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