简体   繁体   中英

Docusign Document blank after API call

Im making a call via Request to docusign like so:

 var options = {
    method: 'GET',
    url: `${baseUrl}/envelopes/${envelopeId}/documents/${documentId}`,
    headers: headers,
    qs: {
        encoding: 'base64'
    }
};

request(options, function (error, response, body) {
...
})

Im getting back the document string but when I write it to a .pdf I get 4 blank pages. Here is the code im using to write it to a file:

fs.writeFile('cert.pdf', body, (err) => {
            if(err) throw new Error(err)
        })

Nodejs -v 8.11.1

Two issues:

  1. I'd leave out the qs: {encoding: 'base64'} option. The document will be returned as a binary file. (Which is what you want.)

  2. When you write the file, specify binary format. On a Linux system, there is no difference. But on Windows there is.

For a code example of retrieving a document, see this file .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM