ZCLI Image upload Issue



Publicado 10 jun 2024

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

15 comentarios

Im experiencing the exact same issue. I'll be glad if there would be a solution to the problem.

0


Tagging along with this as we're currently experiencing the exact same issue, hope that's fine.
Could any findings be shared on this thread?

0


If you don't mind, I can go ahead and pull you into a ticket so I can get a better look at what's going.

0


we tried passing “test” and other keywords still same issue.

0


Hi Harshit!
 
Hmm that is odd behavior. Out of curiosity, how long is the file name that you're using? 

0


Iniciar sesión para dejar un comentario.

¿No encontró lo que buscaba?

Nueva publicación