1

I am trying to retrieve the signed documents from Docusign - and save the PDF file locally. I have tried multiple ways to attempt to extract the PDF out of the returned cfhttp data.

Seems I can get the correct number of pages in the PDF document I download - but they view as all blank with messages of invalid signature. My guess is that I am not parsing multiple PDF files from the filecontent in the returned cfhttp variable but not finding how to do this anywhere. My current code is similar to:

<cfhttp url="https://demo.docusign.net/restapi/v2/accounts/#variables.ACCOUNT#/envelopes/#url.ENVELOPE_ID#/documents/combined" method="GET" resolveurl="Yes" throwonerror="No" result="MY_INFO">
    <cfhttpparam name="X-DocuSign-Authentication" type="HEADER" value="<DocuSignCredentials><Username>#variables.userName#</Username><Password>#variables.password#</Password><IntegratorKey>#variables.integratorKey#</IntegratorKey></DocuSignCredentials>">
    <cfhttpparam name="Content-Type" type="HEADER" value="application/json">
    <cfhttpparam name="Accept" type="HEADER" value="application/json">
</cfhttp>

<cffile action="write" file="D:\Inetpub\Wwwroot\docusign\completed\mypdf.pdf" output="#TRIM(MY_INFO.FileContent)#">
Torsten
  • 29
  • 3
  • I'm not aware of the requirements in CF, but all the other languages I've used makes you define the file type as well as the name.extension. Also you can remove the "Accept" portion of your call, that's requesting that the call come back in json, but it will give you the PDF data instead. And this call is for the certificate, not for a document. I would expact only the certificate to come back with that code. – Andrew Aug 28 '14 at 16:55
  • 3
    _My current code is similar to_ That is not really going to help us help you. It would be best if you could come up with a short self-contained example that shows your problem. – Miguel-F Aug 28 '14 at 17:00
  • i have attempted to removed the accept portion...i have attempted to change it to pdf...neither worked. according to the api documentation - the /documents/combined is for "This retrieves a PDF containing the combined content of all documents and the certificate." so not sure what else i can use. - as for an example - i thought that is what i provided in my question - it is my exact code...i have an existing completed envelope (#url.ENVELOPE_ID#) that i want to bring to my server. – Torsten Aug 28 '14 at 17:09
  • `url="https://demo.docusign.net/restapi/v2/accounts/#variables.ACCOUNT#/envelopes/#url.ENVELOPE_ID#/documents/certificate"` does not say `/documents/combined` – Andrew Aug 28 '14 at 17:31
  • sorry you are correct - i was trying different things when i copied and pasted code and pasted wrong version -- i am actually trying to use /documents/combined. – Torsten Aug 28 '14 at 17:35
  • This is most likely due to a different encoding being used. I don't know Cold Fusion but is there a way of decoding the document bytes in base64 format? If so I'd give that a try... – Ergin Aug 28 '14 at 19:05
  • found the solution - instead of trying to write the file via the cffile - i added path="D:\Inetpub\Wwwroot\docusign\completed\" file="#variables.FILE_NAME#" to the cfhttp call – Torsten Aug 28 '14 at 20:01
  • 1
    Cool, can you please post this as an answer to your question, for the benefit of the community and others using CF? – Ergin Aug 28 '14 at 20:16

1 Answers1

0

Following up here, based on your comments you've solved this:

"Instead of trying to write the file via the cffile - i added

path="D:\Inetpub\Wwwroot\docusign\completed\" file="#variables.FILE_NAME#" 

to the cfhttp call"

Ergin
  • 9,254
  • 1
  • 19
  • 28