I am trying to download attachment via API and stuck as its only helping me with pdf downloads but when downloading other extensions like .csv or .docx or .xlsx the downloaded file is unable to decode the value and shows junk character
How to resolve this? I have tried using base64 decode that's not helpful also Arraybuffer too, below is the representation of my code and work.

Custom code
const parm = {
'realm': realm
};
const parmArray = Object.entries(parm).map(([key, value]) => `${key}=${encodeURIComponent(value)}`);
const joinedParm = parmArray.join('&');
const apiCallUrl = `https://openapi.ariba.com/api/procurement-reporting-attachments/v1/prod/attachment/${uniqueAttachmentId}?${joinedParm}`;
//irpa_core.log(apiCallUrl);
return {
method: 'GET',
url: apiCallUrl,
resolveBodyOnly: false,
rejectUnauthorized: false,
headers: {
Authorization: 'Bearer ' + access_token,
apiKey: apiKeyValue
}
};
Chaitanya Priya Puvvada , Prasanth Padmanabhan Menon , Amith Nair , Thomas Jentsch
TIA