【问题标题】:How to pass document to updateDocument method of DocuSign Java SDK如何将文档传递给 DocuSign Java SDK 的 updateDocument 方法
【发布时间】:2021-02-23 17:57:22
【问题描述】:

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

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

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

我可以使用记录在 here 中的其余 api 来做到这一点。它表示文档正文作为请求正文发送。文档中提到的SDK方法是Envelopes::updateDocument

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

public void updateDocument(String accountId, String envelopeId, String documentId) 抛出 ApiException {...}

那么我们如何使用 SDK 传递文档正文以更新信封中的文档?

【问题讨论】:

标签: java docusignapi


【解决方案1】:

一种可行的方法是定义您的文档,将您的文档添加到信封定义中,然后调用 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();
        }
    }

【讨论】:

    猜你喜欢
    • 2020-06-20
    • 1970-01-01
    • 1970-01-01
    • 2010-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-10-04
    • 2012-02-09
    相关资源
    最近更新 更多