Attachment in a comment trough API | Community
Skip to main content

Attachment in a comment trough API

  • November 29, 2022
  • 11 replies
  • 0 views

Gabriele12

i am having some trouble uploading and add an attachment to a ticket in Zendesk:

my problem is that: the process work without problem but when i try to open the file in zendesk it return me an error loading

My question is: can i upload a file by an http url? cause in the official documentation it add only local files

The process is the following: I receive an input like this  [ { "size": 49890, "attachment content": "https://test.atlassian.net/rest/api/2/attachment/content/10126", "filename": "Screenshot 2022-11-29 at 13.49.01.png", "author": "CPS", "mimeType": "image/png" } ]

and i use this HTTP request for make the call: Endpoint: /api/v2/uploads.json?

Header:

Content-Type mimeType

--data-binary attachment content

and after i make another HTTP request: endpoint: /api/v2/tickets/idticket

body {"ticket": {"comment": {"body": "Attachment:","uploads": ["{{$json["token"]}}"]}}}

11 replies

  • December 1, 2022
Hi Gabriele,
 
You'll want to make sure the Content-Type is set to application/binary for external source file uploads. Also, could you try opening the attachment in Zendesk into a new tab? 
Please let me know if you're able to do so, this will better help me to troubleshoot the issue you're having.
 
Best,
 
Erica

Gabriele12
  • Author
  • December 2, 2022

Hello Erica,

Thanks for helping me!
I've tried to set the Content-Type to application/binary, but doesn't work.
And also open it in a new tab, but doesn't work same.


Gabriele12
  • Author
  • December 6, 2022

Hello @erica26, do you have any other suggestions?


  • December 6, 2022
Hi Gabriele,
 
Apologies for the delay, I was out of the office for a bit. That's definitely very strange then. Let me go ahead and pull you into a ticket so we can get a better look.
 
Best,
Erica

Gabriele12
  • Author
  • December 6, 2022

Hello @erica26,

Sorry I didn't mean to be pushy, but I need to fix it asap.

I will give you more details about the HTTP request:

POST 
https://sendinblue.zendesk.com/api/v2/uploads.json

query
filename
Screenshot 2022-12-06 at 15.42.30.png

Headers
Content-Type 
application/binary

Body
--data-binary
"https://url...."

 

I hope it's all clear and can help you.

Thanks!


  • December 6, 2022
Hi Gabriele,
 
I went ahead and created a ticket for you but can share with you here as well the question that I had. 
 
I noticed the external url for the attachment is to Jira. Do you know if that url is publicly accessible or does it require authentication to access it?
 
If it does require authentication, that could be why you're unable to view it after attaching it. Any external sources for attachments would need to be publicly accessible for it to be viewable.
 
Best,
 
Erica

Gabriele12
  • Author
  • December 7, 2022

Hello!!
Yes the url is from Jira issue, and I can open the link/attachment if I open it in a new browser tab, so it doesn't required the authentication.
Thanks


  • December 8, 2022

I bet this is the same issue I has faced. ZAF client will not work with

Content-Type 
application/binary

You will need to use for example javascript fetch to call the Zendesk api:
https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch

But there you will need to provide a authorization header, and you can't use secure settings to my knowledge. So it is a bad solution to a oversight on Zendesks end.


Gabriele12
  • Author
  • December 8, 2022

Hello, Thanks @tuomas

Can you give me more details, please?

I am doing this request in n8n.


Gabriele12
  • Author
  • December 13, 2022

Can we avoid this problem converting the file in binary?


Gabriele12
  • Author
  • December 14, 2022

Fixed uploading the file in Binary