java - 如何将文档传递给 DocuSign Java SDK 的 updateDocument 方法
问题描述
我对使用 DocuSign 比较陌生,我正在尝试使用它发送电子邮件。
我想使用 Java SDK 在 DocuSign 中创建和更新信封。
我可以使用 templateId 创建一个信封,现在我想使用 documentId 替换信封中的一个文档。
我可以使用此处记录的其余 api 来做到这一点。它表示文档正文作为请求正文发送。文档中提到的 SDK 方法是Envelopes::updateDocument
.
但是当我尝试使用 SDK 时,updateDocument
只需要三个参数,签名是
public void updateDocument(String accountId, String envelopeId, String documentId) 抛出 ApiException {...}
那么我们如何使用 SDK 传递文档正文以更新信封中的文档?
解决方案
一种有效的方法是定义您的文档,将您的文档添加到信封定义中,然后调用 updateDocuments 方法传递您的信封定义。
public static String AddDocument(ApiClient apiClient, String envelopeId, String accountId, String docPath)
{
try {
String retVal;
EnvelopesApi api = new EnvelopesApi(apiClient);
//******************* Add Document*********************
ArrayList documents = new ArrayList<Document>();
byte[] fileBytes = null;
Document doc = new Document();
Path path = Paths.get(docPath);
fileBytes = Files.readAllBytes(path);
doc.setName("Stop Payment Request");
String base64Doc = Base64.encodeToString(fileBytes, false);
doc.setDocumentBase64(base64Doc);
doc.setDocumentId("1");
doc.setFileExtension( "pdf");
documents.add(doc);
EnvelopeDefinition envelope1 = new EnvelopeDefinition();
envelope1.setDocuments(documents);
EnvelopeDocumentsResult result = api.updateDocuments(accountId, envelopeId, envelope1);
retVal = result.getEnvelopeId();
return retVal;
}
catch(Exception e)
{
return e.getMessage();
}
}
推荐阅读
- networking - 关于GBN协议,单个定时器如何跟踪发送未确认数据包的时间?
- php - phpseclib3 SFTP 脚本在本地工作但不能在 cPanel 上工作
- python - 烧瓶插件如何覆盖模板?
- mysql - MySQL LOAD DATA - 可以忽略页脚行吗?
- javascript - 与 parentNode 一起返回的子元素
- xml - 元素“xs:schema”的前缀 xs 未绑定
- flutter - 在颤振中使用地图时出现NoSuchMethodError
- c# - WPF - 数据更改时移动拇指
- flask - 连接 Flask 和 ElectronJS 的最佳方式
- python - What is the logic behind "compute()" in Dask dataframes?