ZCLI Image upload Issue



已于 2024年6月10日 发布

We have created a Zendesk application, and we need to upload an image and use the response ID in the side conversation mail API.

We have implemented the Zendesk Attachment API and are familiar with how it works. We have tested the side conversation attachment API in POSTMAN, and it works fine. However, when we try to use the same API in our Zendesk application using the Client. Request API call, we encounter the following error.  We have tried multiple things like changing the content type and debugging the uploaded file data but nothing works. Please take a look at the screenshot and sample code provided.

 

Following ENDPOINT we are referring: https://developer.zendesk.com/api-reference/ticketing/side_conversation/side_conversation_attachment/

https://developer.zendesk.com/api-reference/ticketing/side_conversation/side_conversation/

 

 

function uploadImage() {
 
  let files = document.getElementById("mail-body-input").files;
  const fileToUpload = files[0];
 
  const formData = new FormData();
  formData.append("file", fileToUpload);
 
  client.request({
    url: `/api/v2/tickets/side_conversations/attachments.json`,
    method: "POST",
    contentType: "multipart/form-data", // Let the browser set the content type with boundary
    body: formData,
    redirect: "follow"
  })
  .then((response) => {
    console.log("Image uploaded successfully", response);
  })
  .catch((error) => {
    console.error("Error uploading image", error);
  });
}

0

15

0 条评论

登录再写评论。

找不到所需的内容?

新建帖子