zeeshanshanif

get pdf document

0 votes
Hi, I want to get pdf document. In POSTMAN var request = require("request"); var options = { method: 'GET', url: 'https://sandbox.esignlive.com/api/packages/{packageId}/documents/{documentId}/pdf', headers: { 'postman-token': '731de084-90fd-c0ac-2fff-346723de7315', 'cache-control': 'no-cache', 'content-type': 'application/json', accept: 'application/pdf', authorization: 'Basic -----------------------------------------------------------==' } }; request(options, function (error, response, body) { if (error) throw new Error(error); console.log(body); }); But I can't open the file. In foxit reader I found this error(Capture.png) and in chrome I found "Failed to load pdf document". Also I use this in my app but found same error. Please point out where I am wrong. ---------- Regards Zeeshan hanif

Attachments
Approved Answer

Reply to: get pdf document

0 votes
Hey Zeeshan, You are almost there. In the sample code you posted above (assuming you are using Node.js), you are getting the response from esignlive but you are not writing the data (i.e. the pdf) anywhere. The quick and easy way would be something like:
var options = { method: 'GET',
  url: 'https://sandbox.esignlive.com/api/packages/fF-ri8cOGtm6YzzhzdOYDJVtRF0=/documents/f8629acded9734a1/pdf',
  headers: 
   {
     accept: 'application/pdf',
     authorization: 'Basic api_key' },
   };

request(options).pipe(fs.createWriteStream('./something.pdf'));
If you want to test this on postman, all you have to do is click on the arrow next to "Send" and select "Send and Download". See my attachment. Hope this helps :)
Haris Haidary OneSpan Technical Consultant

Attachments

Reply to: get pdf document

0 votes
Thanks harishaidary. This is working :) If I want to get document summary What should I do? please guide me

Reply to: get pdf document

0 votes
You can have a look at this quick start guide: https://developer.esignlive.com/guides/quick-start/check-package-status-and-download-documents-rest/ It shows you how to retrieve the evidence summary with the REST API.
Haris Haidary OneSpan Technical Consultant

Hello! Looks like you're enjoying the discussion, but haven't signed up for an account.

When you create an account, we remember exactly what you've read, so you always come right back where you left off