I am trying to fetch images using SFDC rest API where I can see different types of responses for corresponding javascript file and image. Image retrieved shows a message of "Not supported format" but my javascript file works fine.
These are some screenshots of the responses :
Following is my node JS code for retrieving the attachments from knowledge articles:
function createFile(attachmentBody, attachmntContentType, attachmntName) {
var req = {
url: attachmentBody,
method: 'GET',
headers: {
"Content-Type": attachmntContentType
}
};
var test = conn.request(req, function (err, resp) {
if (err) {
console.log(err)
} else {
var fileBuffer = Buffer.from(resp, 'binary').toString('base64');
fs.writeFile(attachmntName, fileBuffer, {
encoding: 'base64'
}, function (err) {
if (err)
throw err
console.log('File saved.')
})
}
});
}
Please help me with this.