Skip to Content
0
Apr 08, 2023 at 11:18 AM

Downloading attachment via API call SAP Build Process Automation - SPA

503 Views Last edit Apr 08, 2023 at 04:25 PM 3 rev

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.

image.png

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

Attachments

image.png (24.4 kB)