-->

DocuSign Rest API - Downloading Completed Document

2019-09-16 08:57发布

问题:

I'm trying to download completed document(s) from a Docusign Envelope sing the below code:

byte[] fileData = envelopesApi.getDocument(accountId, envelopeId, documentId);

However, I think the problem lies with how I'm sending the documents in compositeTemplates that make up the envelope. I'm assigning both documents an ID that corresponds to a custom POJO object's ID in my application. The above envelopesApi.getDocument(accountId, envelopeId, documentId) code worked great until I implemented the compositeTemplate design describe here.

Do I need to use a different ID for each document?

Should I be using a different API call to get back these documents? There will likely be more than two compositeTemplates in the future. So I'll need a way to download all documents in a given envelope.

Thanks for your help.

回答1:

The document Id's can be retrieved using the listEnvelopeDocuments api.

Sample Json Response

{
  "envelopeId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",
  "envelopeDocuments": [
    {
      "documentId": "1",
      "name": "document one",
      "type": "content",
    },
    {
      "documentId": "2",
      "name": "document two",
      "type": "content",
    },
    {
      "documentId": "certificate",
      "name": "Summary",
      "type": "summary",
    }
  ]
}

You can then download the documents by passing the correct documentId to the getEnvelopeDocument api.

The documentId also takes two special values

  • combined Retrieve a PDF that contains the combined content of all documents and the certificate.

  • archive Retrieve a ZIP archive that contains all of the PDF documents, the certificate, and any .WAV files used for voice authentication.