https://api.na1.echosign.com/api/rest/v5/agreements/{agreementId}/combinedDocument
I am trying to create a file from the body of the response, but it is creating a file that I can't open. It requires a password even though there isn't one on the file. I think this must have something to do with the encoding / decoding.
I am using a node express server. Here are the few lines of code I am using:
var request = require('request');
request({
baseUrl: 'https://api.na1.echosign.com/api/rest/v5',
url: '/agreements/' + req.params.id + '/combinedDocument',
headers: {'Access-Token': process.env.ECHOSIGN_INTEGRATIONKEY}
},
function(error, response, body){
if(error) {
res.send(error);
}
else {
var buf = new Buffer(body)
res.set({
'Content-Disposition': 'attachment; filename=test.pdf',
'Content-Type': 'application/pdf; charset=utf-8'
});
res.write(buf);
res.end();
}
}
);