Zoho Mail API - Upload Attachment

Zoho Mail API - Upload Attachment

https://www.zoho.com/mail/help/api/post-upload-attachments.html

I followed the steps from the API documentation and wrote a backend in JavaScript to send emails. Normal emails are sent without any problems. However, I can’t send emails with attachments.

As the documentation says, I first try to upload the file, but I get the following output:


  1. {"errorCode":"UPLOAD_RULE_NOT_CONFIGURED","status":{"code":404,"description":"Invalid Input"}}

I researched for hours and checked the documentation many times, but I can’t understand what the problem is. Why am I getting this error? Here is how I make the request:

  1. const formData = new FormData();
  2. formData.append("file", opts.file, opts.file.name || "attachment");

  3. const uploadRes = await fetch(`${baseUrl}/messages/attachments?uploadType=multipart`, {
  4. method: "POST",
  5. headers: {
  6.   Authorization: `Zoho-oauthtoken ${accessToken}`,
  7. },
  8. body: formData,
  9. });