如何将文档传递到DocuSign Java SDK的updateDocument方法

如何将文档传递到DocuSign Java SDK的updateDocument方法,java,docusignapi,Java,Docusignapi,我对使用DocuSign比较陌生,我正在尝试使用它发送电子邮件 我想使用Java SDK在DocuSign中创建和更新信封 我可以使用templateId创建信封,现在我想使用documentId替换信封中的一个文档 我可以使用文档中的RESTAPI来完成这项工作。它表示文档主体作为请求主体发送。文档中提到的SDK方法是Envelopes::updateDocument 但是当我尝试使用SDK时,updateDocument只接受三个参数,签名是 public void updateDocume

我对使用DocuSign比较陌生,我正在尝试使用它发送电子邮件

我想使用Java SDK在DocuSign中创建和更新信封

我可以使用templateId创建信封,现在我想使用documentId替换信封中的一个文档

我可以使用文档中的RESTAPI来完成这项工作。它表示文档主体作为请求主体发送。文档中提到的SDK方法是
Envelopes::updateDocument

但是当我尝试使用SDK时,
updateDocument
只接受三个参数,签名是

public void updateDocument(字符串accountId、字符串envelopeId、字符串documentId)引发异常{…}


那么,我们如何使用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();
        }
    }
publicstaticstringadddocument(ApiClient-ApiClient、stringenvelopeid、stringaccountid、stringdocpath)
{
试一试{
字符串检索;
信封api=新信封api(apiClient);
//*******************添加文档*********************
ArrayList documents=新的ArrayList();
byte[]fileBytes=null;
单据单据=新单据();
Path=Path.get(docPath);
fileBytes=Files.readAllBytes(路径);
文件setName(“停止付款请求”);
字符串base64Doc=Base64.encodeToString(fileBytes,false);
文件setDocumentBase64(base64Doc);
文件setDocumentId(“1”);
doc.setFileExtension(“pdf”);
文件。添加(doc);
信封定义信封1=新信封定义();
信封1.文件(文件);
EnvelopedDocumentsResult结果=api.updateDocuments(accountId、envelopeId、envelope1);
retVal=result.getEnvelopeId();
返回返回;
}
捕获(例外e)
{
返回e.getMessage();
}
}
您尝试过updateList吗