How can I get the active document file data in doc/docx format? I can get the content in the PDF format without any issue. I have tried below apps script code, but it didn't return the base64 string in doc/docx format.
var doc = DocumentApp.getActiveDocument();
function doPostRequest(){
var newblob = doc.getBlob();
newblob.setContentType("application/msword");
newblob.setName("sample.doc");
var dataObj = {
date : new Date(),
subject : "sample file data",
comment : "this is a test comment",
attachment : newblob
};
var options = {
method : 'POST',
payload: dataObj
};
var response = UrlFetchApp.fetch('https://postman-echo.com/post', options);
console.log(response.getContentText());
return response.getContentText();
}
Output
Although it says "sample.doc", when I copy-pasted and generated a file from the base64 string (using C#) it opened as a PDF file.
How to convert the file data into doc/docx format and save the file data as a doc/docx file?