'zoho send email with cloudflare workers 400 Bad Request {"data":{"errorCode":"INVALID_TICKET","moreInfo":"Invalid ticket"}

good afternoon

I read this topic, but it did not help me https://help.zoho.com/portal/en/community/topic/api-returns-invalid-ticket

I am trying to use https://www.zoho.com/mail/help/api/email-api.html through cloudflare workers this is the code

addEventListener("fetch", event => {
  event.respondWith(handleRequest(event.request))
})

async function handleRequest(request) {
  let respContent = "";
  let send_request = new Request("https://mail.zoho.com/api/accounts/15****************/messages", {
      method: "POST",
      body: JSON.stringify({
          fromAddress: "[email protected]",
          toAddress: "[email protected]",
          subject: "Email - Always and Forever",
          content: "Email can never be dead. The most neutral and effective way, that can be used for one to many and two way communication.",
          askReceipt : "yes"
      }),
  });

  if( request.method == "POST" ) {

      const resp = await fetch(send_request);
      const respText = await resp.text();

      respContent = resp.status + " " + resp.statusText + "\n\n" + respText;
  }

  let htmlContent = "<html><head></head><body><pre>" +
      '</pre><p>Click to send message: <form method="post"><input type="submit" value="Send"/></form></p>' +
      "<pre>" + respContent + "</pre>" +
      "</body></html>";
  return new Response(htmlContent, {
      headers: { "content-type": "text/html" },
  })
}

but this error code appears enter image description here

even I generate aithtoken and get AcoountId from it enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source