Hi Everyone, I’m trying to convert a base64 pdf stream to a pdf file and attach it to a fresh service ticket.
In my request to Docusign (where I get the base64pdf stream), I set the content transfer encoding to be in base 64.
“Content-Transfer-Encoding” : “base64”
I then use the code below to try and turn that base64 stream into a pdf to attach to a fs ticket.
// Using Axios to get Docusign PDF in base64 format
const DOCUSIGN_REQUEST = await axios.get(DOCUSIGN_URL,DOCUSIGN_OPTIONS);
var testing_decoder = DOCUSIGN_REQUEST.data;
//form to send to Freshservice to upload the pdf file
const form = new FormData();
//this is where the data for the file is added.
form.append("attachments[]",DOCUSIGN_REQUEST.data,{filename: "pleasework.pdf"});
//body of the note
form.append("body", "This is a test note to attach a pdf file to the ticket");
//logging response sent to Freshservice
console.log(form)
//sending request to post the pdf file to Freshservice
const FS_POST_REQUEST = await axios.post(URL,form, {
headers : {
"Authorization": "Basic <Authorization code>",
}
}
)
}
catch (error) {
console.error(error);
}
It attaches the pdf however the data is corrupted and it returns the pdf with data seen in the screenshot below. Please let me know if you have any tips on how to get this converted correctly. Thank you.