Recent searches
No recent searches
Image upload via upload api
Posted Sep 28, 2021
My requirement is to give customer option to upload image & this image needs to be send to zen desk. Do I need to upload the image on some server before using the upload function of zen desk.
Following is the code i m trying, but its not working
$uri = 'https://company.zendesk.com/api/v2/uploads.json?filename=image.jpg';
$target_file = $_FILES['file']['tmp_name'];
$fildata = file_get_contents($_FILES["fileToUpload"]["tmp_name"]);
$ch = curl_init();
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_MAXREDIRS, 10 );
curl_setopt($ch, CURLOPT_URL, $uri);
curl_setopt($ch, CURLOPT_USERPWD, "xxxx@test.com/token:xxxxx");
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/binary'));
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $fildata);
curl_setopt($ch, CURLOPT_INFILE, $file);
curl_setopt($ch, CURLOPT_INFILESIZE, $size);
curl_setopt($ch, CURLOPT_USERAGENT, "MozillaXYZ/1.0");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
curl_setopt($ch, CURLOPT_VERBOSE, true);
$output = curl_exec($ch);
0
5 comments
Eric Nelson
Hey Shweta,
If you go to the admin panel then down to settings/customers do you see that 'Require authentication for request and uploads APIs' is enabled?
Thanks!
Have a wonderful day!
Eric Nelson | Manager - Developer Advocacy
0
lisahaley
Hi I am also facing same problem.Can you send screen shot of this so that i can use upload api for image uploading?
Regards,
Awaiting for your nice response.
0
Eric Nelson
Hey Lisa,
Are you looking for a screenshot of where the setting is in your Zendesk interface?
Have a wonderful day!
Eric Nelson | Manager - Developer Advocacy
0
Shweta Srivastava
Hi Eric,
The setting is unticked for now. My understanding is it has to be unticked only.
Thanks
0
Will Ryan
This is the only thing that would work for me. If i didn't do it like this, a blank image was appearing in the response:
0