Skip to main content


Hi






I am making a request with Jquery in javascript. When I try to authaorize, I get this message:



require_login: true


Here is the code:





$.ajax({

type: 'POST',

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

beforeSend: function( xhr ) {

xhr.setRequestHeader("Authorization", "Basic " + btoa("My_API_KEY:X"));

},

data: {

"helpdesk_ticket":{

"description":"Some details on the issue ...",

"subject":"Support needed..",

"email":"tom@outerspace.com",

"priority":1,

"status":2

},

"cc_emails":"ram@freshdesk.com,diana@freshdesk.com"

}

}).done(function( data ) {

console.log( data );

})




There's obviously something wrong with the way I set the header, but I cannot understand how I am supposed to do it.






Thanks for all help :)







It appears that you are trying to use the v1 API. Could you try the newer v2 instead? It's easier to use and the error messages are much more descriptive which will help you debug.






v2 docs - https://developers.freshdesk.com/api/#introduction






JS Code sample - https://github.com/freshdesk/fresh-samples/blob/master/jquery/create_ticket.html






I must have been sleeping... I used the v1 API and forgot to point the request to our Freshdesk-domain. It worked in v2 :)