Skip to main content


Hi, I have a question on creating a ticket. here is the code I use from https://github.com/freshdesk/fresh-samples.






var yourdomain = 'mydomain...';



var api_key = 'my key...';



var ticket_data = '{ "description": "Details about the issue...", "subject": "Support Needed...", "email": "tom@outerspace.com", "priority": 1, "status": 2, }';



$.ajax(



{



url: "https://"+yourdomain+".freshdesk.com/helpdesk/tickets.json",



type: 'POST',



contentType: "application/json; charset=utf-8",



dataType: "json",



headers: {



"Authorization": "Basic " + btoa(api_key + ":x")



},






data: ticket_data,



success: function(data, textStatus, jqXHR) {



console.log(data);



console.log(textStatus);



console.log(jqXHR);



},



error: function(jqXHR, tranStatus) {



console.log(jqXHR);



console.log(tranStatus);



}



}



);






When I request it, it kept telling me I have a bad request as the JSON format is invalid. I am not sure what I did wrong in this case. Can someone help me with this issue on what I did wrong?





Hi Ted,






Just checked on your request and it looks like you are in touch with one of our customer support executives. We'll follow up on this on the support ticket.






Cheers!