Hi everyone, i'm making a request to an api to obt...
# general
a
Hi everyone, i'm making a request to an api to obtain a pdf , with this code:
filePDFId = file.create({
name: transactionType + '_' + transactionId + '.pdf' ,
fileType: file.Type.PDF,
contents: responsepdf.body,
description: 'PDF document for ' + transactionType + ' ' + transactionId,
folder: getOutboundDocumentsFolderID('Outbound PDF Documents'),
isOnline: false,
}).save();
but it show me an error , and when i tried to convert to base64, save the pdf in blank. the error without converting is: Intenó escribir datos no binarios en un archivo binario 'invoice_9755.pdf' del tipo 'PDF'. Los datos binarios deben estar codificados como cadenas base64. Usted proporcionó los siguientes datos: %PDF-1.4 %���� 1 0 obj </Producer (Skia/PDF m125) /CreationDate (D:20241210192442+00'00') /ModDate (D:20241210192442+00'00')>> endobj 3 0 obj </ca 1 /LC 0 /LJ 0 /LW 1 /ML 4
k
Can you show the code you're using to do the base64 conversion?
a
The issue is that when I convert it to Base64, the PDF is saved in the cabinet, but it’s empty. However, when I don’t convert it, I get the error I mentioned.
k
So, in your example above - { ..., contents: responsepdf.body, ...} is base64 encoded BEFORE you run file.create()?
a
i test both ways, encoded ( save the pdf but empty) and without encoded show the error that i send before
k
What is the source of the responsepdf.body?
a
image.png
k
Sorry to be slow, but let me try to make sure I'm understanding what you're doing. Are you just trying to pull (https.get) an existing PDF file that's sitting in a folder in the file cabinet? Or, are you trying to put a new file from outside NetSuite into an existing folder inside NetSuite?
a
I am trying to place a new file from outside NetSuite that is returned to me by an endpoint and I want to save it in an existing folder within NetSuite, but when I save it I get that error
n
I'd be curious to see the output of responsepdf.body
a
image.png
n
Looks like a corrupted data issue, if you encode it it so responsepdf.body is empty?