I would like to be able to have our costumers attach an image to a costum form that creates tickets in freshdesk.
I haven't been able to find much information on the subject, but this is what i found: https://support.freshdesk.com/support/discussions/topics/17744
I'll compress and encode the image in my end, and that works great, but i'm having some trouble when making the json object and sending it to freshdesk. This is how i imagine it should look like (and what i've tested):
all my costum fields
Everything works great without the "attachments" object.
//BASE64// is my base 64 string, which works fine on it's own.
This, however, gives me a "we're sorry something went wrong" error..
Does anyone know what i'm doing wrong?
Thanks in advance,
I've talked to support, and they've informed me that attachments is only supported trough xml.
UPDATE: support just got back to me again and told me it's possible - still without a solution. will update if/when i get one
Did you ever get a working solution for this?
Unfortunately not my ideal solution, but it works!
My ideal solution would be:
-> Make JSON object in js with ticket info
-> send image to a php file (via ajax and form data) that will compress it, and return a base64 string
-> add base64 string to JSON object
-> send object to php file via ajax
-> add ticket with curl
This is how i had to do:
-> add all form inputs to a formData object, including the chosen image, and send these to a php file.
-> the php file will:
- make variables of all the POST fields from the formData
- compress/resize image and UPLOAD it (this is what i initially wanted to avoid)
- make a php array with all the data (much like i would make the JSON object in js) including the image path
- add this ticket to fresh desk
- unlink (delete) image.
If that makes sense to you, here is some pseudo code (NOT tested and rather quickly written, so be aware of mistakes):
I hope you, and maybe others, can make use of this :)
If someone has found a way to do this as i initially wanted (with JSON only and base64) i'd love to see it!
EDIT: did some edits in the code
EDIT2: just some more edits for clarity
EDIT3: just some more code edits
EDIT4: added a little word of advice to the php code :)
excelente, it has served me well
this I need to manipulate a custom field
You could use the sample PHP code in the below URL to create a ticket with an attachment.
It should help.