Download multiple attachments as ZIP file

I want to download the multiple attachments as zip files.

I have successfully implemented a method using the fetch API to download multiple attachments as zip files. However, when attempting to replicate the same functionality using the client method, I encountered a 403 error.

Below, I am providing the code snippets.

working code with the fetch method:

var myHeaders = new Headers();
        myHeaders.append("X-Requested-With", "application/xml");
        // myHeaders.append("Access-Control-Allow-Origin", "*");

        var requestOptions = {
          method: 'GET',
          headers: myHeaders,
        };
        const data = await fetch(`https://fw-cors.spritle.com/${each.attachment_url}`, requestOptions);

client code:

const data = await client.request.invokeTemplate(
          "AllDownAtt",
          { context: { attachment_url: each.attachment_url } }
        );

Schema:

"AllDownAtt": {
        "schema": {
            "method": "GET",
            "protocol": "https",
            "host": "fw-cors.spritle.com",
            "path": "/<%= context.attachment_url %>",
            "headers": {
                "X-Requested-With": "application/xml"
            }
        }
    },

this was the error i am getting:

{
    "status": 403,
    "headers": {
        "server": "nginx/1.14.0 (Ubuntu)",
        "date": "Fri, 15 Mar 2024 12:03:57 GMT",
        "content-type": "text/xml",
        "content-length": "110",
        "connection": "close",
        "x-request-url": "https://spritlesoftware.attachments8.freshdesk.com/data/helpdesk/attachments/production/26057978088/original/image+with+3mb.avif?Expires=1710504532&Signature=jvSrE2iG482~hDdJeqLpw9OSGO-NiTjQOOFfPMPxEsW3PEY8u18FnOXIotpIvtdnJYRqt715qfU4ToAS6hMmT3Gwt3G6VqcWvs8R6HSom1VsLjCBy7O6zs6PSbNt55mVdSoxWCdBXHPWBmQChhV1FaexxkGWmg24wotktfB88ebWC61uUpi2zZuEG~zb28xGSgLlKoh7f-OPNQh1eLil7j8DKnsZJkZGinahbXJCh-H0kXksIQJunyJ75dIusJioftazvyMfAU4wH7ruwL88hG84LCxwSsfMazM6Vc~65cUigJPwlCPItqso8OSkrDQuPgSovfC62FLju7GAO2ND5w__&Key-Pair-Id=APKAJ7JARUX3F6RQIXLA",
        "x-cache": "Error from cloudfront",
        "via": "1.1 6c7a5d26be7fb35284e54d321f16b6f6.cloudfront.net (CloudFront)",
        "x-amz-cf-pop": "FRA56-C2",
        "x-amz-cf-id": "eYKI6y4R-ZbAjR4wUtKNv_gjyjMqpXIrD3kVy3BkVmtluIH43d4WYA==",
        "x-final-url": "https://spritlesoftware.attachments8.freshdesk.com/data/helpdesk/attachments/production/26057978088/original/image+with+3mb.avif?Expires=1710504532&Signature=jvSrE2iG482~hDdJeqLpw9OSGO-NiTjQOOFfPMPxEsW3PEY8u18FnOXIotpIvtdnJYRqt715qfU4ToAS6hMmT3Gwt3G6VqcWvs8R6HSom1VsLjCBy7O6zs6PSbNt55mVdSoxWCdBXHPWBmQChhV1FaexxkGWmg24wotktfB88ebWC61uUpi2zZuEG~zb28xGSgLlKoh7f-OPNQh1eLil7j8DKnsZJkZGinahbXJCh-H0kXksIQJunyJ75dIusJioftazvyMfAU4wH7ruwL88hG84LCxwSsfMazM6Vc~65cUigJPwlCPItqso8OSkrDQuPgSovfC62FLju7GAO2ND5w__&Key-Pair-Id=APKAJ7JARUX3F6RQIXLA",
        "access-control-allow-origin": "*",
        "access-control-expose-headers": "server,date,content-type,content-length,connection,x-cache,via,x-amz-cf-pop,x-amz-cf-id,x-final-url,access-control-allow-origin"
    },
    "response": "<?xml version=\"1.0\" encoding=\"UTF-8\"?><Error><Code>AccessDenied</Code><Message>Access denied</Message></Error>",
    "attempts": 1,
    "errorSource": "APP"
}

Thanks in advance.

Hi @balanagendra,

Greetings!

This happens if the link stays for way too long for pdf (For this I have faced this 403 issue).

On Download, you can check for the pdf type in the download list and if so, re-fetch the link again and download.

Let me know if that works for ya!

Thank you.

is there any update team?