Skip to main content

Posts

Showing posts from March, 2018

Gotchas when downloading PDFs from Zoho Creator using Node JS

I spent a confusing 90 minutes trying to figure out how to download PDFs from Zoho Creator from a Node JS API. (Backstory is that I wanted to be able to email a Zoho Creator HTML page as a PDF attachment to customers). There are two gotchas I discovered: 1. There is a 302 redirect from the URL that Zoho gives you in their documentation (e.g. https://creator.zohopublic.com/customer/app/pdf/HTML_Page/PUBLIC_SHARE_KEY) to a URL like this: https://creator.zohopublic.com/exportData.do?sharedBy=customer&appLinkName=app&viewLinkName=HTML_Page_Link_Name&privatelink=PUBLIC_SHARE_KEY&fileType=pdf You either have to use followRedirects or use the second URL. 2. Zoho Creator won't actually give you a real PDF unless you supply a realistic user agent. I spent a good hour trying to figure out why I kept getting 0 bytes back when downloading the PDF from my code. The solution was to pretend to be a browser to get the PDF.