Getting 403 access denied when trying to download attachment from conversation item

when I get conversations from converssations API end point I get the attachments list for each conversation item.
After that in server.js I try to get the attachment like this:

              const response = await axios({
                  method: "GET",
                  url: attachment_url,
                  responseType: 'arraybuffer',
              });

where my attachment_url looks like this: https://kontrave.attachments-euc9.freshdesk.com/data/helpdesk/attachments/production/201023675594/original/WhatsApp+Image+2024-09-18+at+21.43.16_3689ec27.jpg?Expires=1726750091&Signature=Qsscukou3~2hMJQOSKXE5dKthWY0FuunCE2COzhsOQKvQofzPXOWikgZyHpuTFAnT88a43mrCUW6gB8KFkZo6z1IlakflUj6Kcy2FPltropWpW1MHKnQP9e2ncKsWafszU-w7TamSi4RIvUCzzMyOEQgWoHmFJ4TvpCe0mJ4vn2unutINxJm82qFrbojdEFubtGWQP643NoSFeCR0VSwbLv8TRXLMgkFwjEmKT46t2OVYjcUOYyzzBicvgMKB8WeZbVBszyKzqjNmOr9znZprYTLbCqljnCiaVxI1tWe4FaTAke~hdSbWWkAhzKJZPjnel1k9jM-jgyh5kohlpfYDw__&Key-Pair-Id=APKAJ7JARUX3F6RQIXLA

and at the end I get error in the terminal
image

and If I try to acces this link from browser I get this

image

This could be due to the attachment URL being protected or expired. The URL may be pre-signed and only accessible for a limited time or under specific authorization conditions.

The attachment URL contains an Expires query parameter (Expires=1726750091). Check the expiration time and ensure that the URL has not expired. If the URL is expired, you will need to regenerate the URL or re-fetch the conversation from the API to get a fresh URL.

Also, try adding your API key in the headers when accessing the attachment. This might look like:
const response = await axios({
method: “GET”,
url: attachment_url,
responseType: ‘arraybuffer’,
headers: {
Authorization: 'Basic ’ + Buffer.from(‘your_api_key:X’).toString(‘base64’), // Replace ‘your_api_key’ with the actual API key
},
});

I found what it is, the frontend app is converting space characters to + characters when sending payload data to serverless apps…

This topic was automatically closed 6 days after the last reply. New replies are no longer allowed.