Currently I have written the Apps Script code where when a user submits certain details from a Google form, a customized pdf consisting of the mentioned details is generated and saved in a folder on Google Drive. Now I have to send this generated pdf to whatsapp and I have configured whatsapp business account and the app on that platform.
The formData part of my code has a key 'link' with the value pdfUrl, if I replace 'pdfUrl' with any public pdf url, then the pdf is sent. However I want to send the pdf this code generates, which is currently being sent as an html file.
Please let me know how to overcome this problem
const blob = doc.getAs(MimeType.PDF); doc.saveAndClose(); var fn = row[1]+''+row[14]+'.pdf'; const pdf = folder.createFile(blob).setName(fn); let pdfUrl = pdf.getUrl() const formData = {"messaging_product": "whatsapp","to": arr[i],"type": "document","document": {"link": pdfUrl,"filename": fn } }; const options = { 'method' : 'post','contentType': 'application/json','headers': headers,'payload': JSON.stringify(formData) }; const response = UrlFetchApp.fetch(url, options); //Logger.log(response); var data = JSON.parse(response); Logger.log(data);