Discussions
Stay up-to-date with the latest news from NetSuite. You’ll be in the know about how to connect with peers and take your business to new heights at our virtual, in-person, on demand events, and much more.
New AI Community Guidelines. Please review and follow them to ensure AI use stays safe, accurate, and compliant.
How to fix blank PDF file sent using https.put in a SuiteScript?
Hi,
I am new to suitescript and want to implement https.put() to upload a binary file (pdf, docx, image) based on either the file_id from file cabinet or actual file selected by user from his/her computer to upload. In any case, currently when I upload a pdf, a blank pdf is created on the target server. Could you please guide me the steps to follow? Here is the code I wrote
var fileObj = file.load({
id: bm_fileid
});
var putreq_headers = {};
putreq_headers['Content-Type'] = 'application/pdf';
var filecontent = fileObj.getContents();
var filebase64 = encode.convert({
string: filecontent,
inputEncoding: encode.Encoding.BASE_64,
0