I am trying to call the api endpoint getDocument
via Node, and am expecting a Buffer to be returned, however, it is returning a string. Even when I pass in different values for the encoding
optional parameter, the data returned is always the same.
When I tested the same endpoint in C#, a MemoryStream is returned which is expected.
My code is as follows:
const document = await envelopesApi.getDocument(accountId, envelopeId, '1')
Where 1
is the documentId (page 1).
The contents of document
looks like %PDF-1.5\n%ûüýþ\n%Writing objects...
and so on
I am then trying to save this to a file:
fs.writeFileSync('test.pdf', Buffer.from(documentContent))
With no success. How do I get the api response and save it to a file for viewing?