Skip to main content
Question

Attaching file to ticket, file size is larger and broken


Forum|alt.badge.img

I’m trying to use the API to attach a file to a ticket.  I have tried images and PDFs. The file gets attached to the ticket but is broken when viewed in Freshservice. When I get the ticket attachment details using the API, the attachment content-type is “application/octet-stream” instead of “image/jpeg” for the jpg image I tested but correctly set as “application/pdf” for the PDF I tested.  But neither file types work correctly. Image is broken, PDF document is blank.

The file size, according to Freshservice, is always some bytes larger than they actually are locally.  For example, with a very small image that is 1252 bytes locally, Freshservice reports the size as 1702 bytes. Here is the example payload for the small image I’m testing with:
 

--------------------------S1SJJcLLQQJrNanXChw123
Content-Disposition: form-data; name="attachments[]"; filename="test1.jpg"
Content-Type: image/jpeg

????JFIF?????ExifMM*?i&?\?p??52??522024:05:04 11:22:402024:05:04 11:22:40???http://ns.adobe.com/xap/1.0/
2024-05-04T11:22:40.520
??C



%# , #&')*)-0-(0%()(??C



(((((((((((((((((((((((((((((((((((((((((((((((((((??
"??	
???}!1AQa"q2???#B??R??$3br?	
%&'()*456789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz???????????????????????????????????????????????????????????????????????????	
???w!1AQaq"2?B????	#3R?br?
$4?%?&'()*56789:CDEFGHIJSTUVWXYZcdefghijstuvwxyz?????????????????????????????????????????????????????????????????????????????????m-????+?????v???"
?y?s?QEr?Y?D???e?G??
--------------------------S1SJJcLLQQJrNanXChw123
Content-Disposition: form-data; name="priority"

1
--------------------------S1SJJcLLQQJrNanXChw123--

And what Freshservice API returns for this image in the ticket:

I’m using Coldfusion to work with the API.  Everything else I’m doing with the API (including downloading attachments) works fine, I’m just stuck trying to update a ticket with attachments.  Anyone have any ideas on what to try?

Did this topic help you find an answer to your question?

2 replies

Forum|alt.badge.img
  • Author
  • Contributor
  • 3 replies
  • February 5, 2025

I have tried using Postman to test this and it doesn’t work at all so I’m wondering if there is an issue with the API itself.  Here is the error I’m getting with Postman:

Can anyone confirm adding attachments is actually working for them?


flaresolverr
Community Debut
Forum|alt.badge.img+2
  • Community Debut
  • 6 replies
  • March 9, 2025

Freshservice is misinterpreting the file encoding or adding extra bytes during the upload. Try setting the correct Content-Type explicitly in your request headers and ensure the file is read as binary to avoid encoding issues. Also, check if Freshservice expects base64-encoded data instead of raw file uploads. Tools like Flaresolverr can help bypass API restrictions when automating web interactions.


Reply