0

I would like to generate an ics file then transform it in blob to finally send it through an Zendesk API POST call

The code

const blob = new Blob([icsContent], { type: "application/json" });
const uploadICSFile = await uploadZendeskFile('appointment.ics', blob);

axios POST

export async function uploadZendeskFile(filename: string, fileBlob: Blob): Promise<Upload> {
  return await axios.post(
    `https://${config.subdomain}.zendesk.com/api/v2/uploads.json?filename=${filename}`,
    fileBlob,
    {
      auth: {
        username: '*****',
        password: '*****'
      },
      headers: {
        'Content-Type': 'text/calendar',
      }
    }
  );
}

etrix
  • 59
  • 6

1 Answers1

0

The answer:

Typescript code:

    const blob = new Blob([icsContent], { type: "application/octet-stream" });
    const uploadICSFile = await uploadZendeskFile('appointment.ics', blob);
etrix
  • 59
  • 6