cancel
Showing results for 
Search instead for 
Did you mean: 

Downloading attachment via API call SAP Build Process Automation - SPA

0 Kudos

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
  }
};

chaitanyapriya.puvvada , prasanthpadmanabhan.menon , amiths.nair2 , thomas.jentsch

TIA

View Entire Topic
sakshamjain
Advisor
Advisor
0 Kudos

Hi Indrajit,

You can use the Download File activity to download the file irrespective of the file extension.