Skip to main content
Question

error when downloading the envelope

  • March 17, 2025
  • 1 reply
  • 31 views

Forum|alt.badge.img+1
When downloading the envelope via the application, the completed fields are not shown in the document and the signatures are not shown eithernote: I am using the development environment, my account is not yet in production

app.get('/envelopes/:envelopeId/documents', async (req, res) => {

  await checkToken(req);

  const envelopesApi = getEnvelopesApi(req);

  const envelopeId = req.params.envelopeId;

 

 

 

my code:

  try {

    const docs = await envelopesApi.listDocuments(process.env.ACCOUNT_ID, envelopeId);

    res.json(docs);

  } catch (error) {

    console.error('Erro ao listar documentos:', error);

    res.status(500).send('Erro ao listar documentos');

  }

});


 

app.get('/envelopes/:envelopeId/documents/:documentId', async (req, res) => {

  await checkToken(req);

  const envelopesApi = getEnvelopesApi(req);

  const { envelopeId, documentId } = req.params;

 

  try {

    const envelope = await envelopesApi.getEnvelope(process.env.ACCOUNT_ID, envelopeId);

    if (envelope.status !== 'completed') {

      throw new Error('O envelope ainda não foi concluído.');

    }

 

    const fileContent = await envelopesApi.getDocument(process.env.ACCOUNT_ID, envelopeId, documentId, {

      documentId: documentId,

      envelopeId: envelopeId,

      certificate: false,

      show_changes: false,

      watermark: false,

      encoding: 'utf-8'

    });

 

    res.set({

      'Content-Type': 'application/pdf',

      'Content-Disposition': `attachment; filename="document_${documentId}.pdf"`

    });

 

    res.send(fileContent);

  } catch (error) {

    console.error('Erro ao baixar documento:', error);

    res.status(500).send('Erro ao baixar documento');

  }

});

1 reply

Forum|alt.badge.img+1

Hi @ribeiroanamrb

Make sure that your code is making the API request to the endpoint listed in this documentation to download signed documents from an completed envelope:
https://support.docusign.com/s/document-item?language=en_US&bundleId=oeq1643226594604&topicId=ufg1578456341295.html
You can test it by using our Postman collection as well so it is easier to replicate into your code.
https://developers.docusign.com/tools/postman/

Additionally there is an account setting that you can check, under “Sending Settings” check the option: “When an envelope is sent, write the initial value of the fields for all recipients”. 
This will guarantee, if you retrieve the envelope in any step of the signing ceremony, the fields will be populated.

If you still facing issues after the above suggestion, It is recommend to open a Case to our Support team so we can take a deeper look into the issue.