loweryjk
loweryjk

Reputation: 164

How do you update a docusign envelope document?

In the java below, I create an envelope containing a document, then try to update the document. The create works fine, but I’m getting a file conversion error on the update. I'm using the docusign java client. Any ideas?

    // create
    List<Document> documents = new ArrayList<>();
    Document document = newDocument("1", "title", file);
    documents.add(document);

    EnvelopeDefinition envelopeDefinition = new EnvelopeDefinition();
    envelopeDefinition.setDocuments(documents);
    envelopeDefinition.setStatus("created");
    EnvelopesApi envelopesApi = new EnvelopesApi();
    EnvelopeSummary envelopeSummary = envelopesApi.createEnvelope(accountId, envelopeDefinition);

    // update
    documents = new ArrayList<>();
    document = newDocument("2", "title 2", file);
    documents.add(document);

    envelopeDefinition = new EnvelopeDefinition();
    envelopeDefinition.setDocuments(documents);
    envelopeDefinition.setStatus("created");
    EnvelopeDocumentsResult envelopeDocumentsResult = envelopesApi.updateDocuments(accountId, envelopeSummary.getEnvelopeId(), envelopeDefinition);

the response

class EnvelopeDocumentsResult {
    envelopeId: a826c9f9-75f0-41bc-a958-537c45bc3918
    envelopeDocuments: [class EnvelopeDocument {
        documentId: 2
        name: null
        type: null
        uri: null
        order: 2
        pages: null
        containsPdfFormFields: null
        errorDetails: class ErrorDetails {
            errorCode: FORMAT_CONVERSION_ERROR
            message: The data could not be converted.
        }
    }]
}

Upvotes: 0

Views: 613

Answers (1)

Majid Mallis
Majid Mallis

Reputation: 114

I'm not sure what 'file' variable is. But the DocuSign API requires files to be encoded in Base64. I know the EnvelopeDefinition class is so complex, so I suggest to have a look on this example and compare the code snippet with yours: https://www.docusign.com/developer-center/recipes/request-a-signature-via-email

Also please share envelopeDefinition.toString() (you can anonymize any sensitive data)!

Upvotes: 1

Related Questions