Hi community,
I’m using PHP to make API calls to interact with Freshdesk, and un til today, i had no problem to deal with it.
Right now, i’m facing an issue about attachments files that we can add to the tickets. In fact, i’m trying to use the code samples here :
but i’m very disappointed cause none of the ones who deal with attachments are working.
Could some PHP developer help me ? Somebody made it work on his side ?
Thanks a lot guys, you could help me a lot with this !!
Have a nice day
Anthony
hello could you share your code and error return? I’ve used these examples a few times, I didn’t get any problems!
2 Likes
This code :
<?php
$api_key = "API_KEY";
$password = "x";
$yourdomain = "YOUR_DOMAIN";
$ticket_payload = array(
'email' => 'test@example.com',
'subject' => 'test',
'description' => 'testing description content',
'priority' => 2,
'status' => 2,
'attachments[]' => curl_file_create("data/x.png", "image/png", "x.png")
);
$url = "https://$yourdomain.freshdesk.com/api/v2/tickets";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_POST, true);
This file has been truncated. show original
does not work ! I also used these samples to make a lot of other things like “Create a simple ticket”, “Create a user” but this thing with attachments just dont work.
Could someone please help me ? i’m lost !!!
Hi Anthony
I’m currently dealing with the same problem. Did you find the solution?
Thanks!
Jonathan
irshad
(Irshadahmed Ansari)
February 19, 2024, 6:16am
6
Hello Everyone,
I am facing same issue with this attachment code, please share any solution to this. Creating ticket with attachment using PHP is not working. I am sharing request and response as below:
REQUEST
------------postFields-----------
Array
(
[email] => test@test.com
[subject] => test upload
[description] => test upload
[priority] => 2
[status] => 2
[attachments ] => Array
(
[0] => CURLFile Object
(
[name] => https://domain.com/Giftcardbanner.png
[mime] => image/png
[postname] => Giftcardbanner.png
)
)
)
RESPONSE:
{“description”:“Validation failed”,“errors”:[{“field”:“attachments”,“message”:“It should contain elements of type valid file format only”,“code”:“datatype_mismatch”}]}
Thanks a lot in advance.
REgards,
Irshad
Hey @irshad ,
I’ve shared this feedback/query with the Freshdesk support team. And they would be able to help with this.