简体   繁体   English

API调用后,Docusign文档为空

[英]Docusign Document blank after API call

Im making a call via Request to docusign like so: 我通过Request呼叫docusign,如下所示:

 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. 我取回文档字符串,但是当我将其写入.pdf时,得到了4个空白页。 Here is the code im using to write it to a file: 这是im用于将其写入文件的代码:

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

Nodejs -v 8.11.1 Node.js -v 8.11.1

Two issues: 两个问题:

  1. I'd leave out the qs: {encoding: 'base64'} option. 我会省略qs: {encoding: 'base64'}选项。 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. 在Linux系统上,没有区别。 But on Windows there is. 但是在Windows上有。

For a code example of retrieving a document, see this file . 有关检索文档的代码示例,请参见此文件

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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