freshworks / fresh-samples

Samples of code created by freshdesk
183 stars 182 forks source link

How to send input value throw freshdesk api? Need help asap #76

Open mafioznick opened 2 years ago

mafioznick commented 2 years ago

i need help, how send form input value throw this freshdesk api.. what i need to change, to insert input id in ticket_data as value.. please help

<input id="lc-calendar_till" type="hidden" placeholder="Date from">


<script>
$(document).ready(function(){
    $("button").click( // click to send
      function() {
        var yourdomain = 'domainxxxx'; 
        var api_key = 'apikeyherexxx'; 

 ticket_data = '{ "description": "here is description", "subject": "Subject text", "email": "mail@gmail.com", "priority": 1, "status": 2 }';

        $.ajax(
          {
            url: "https://"+yourdomain+".freshdesk.com/api/v2/tickets",
            type: 'POST',
            contentType: "application/json; charset=utf-8",
            dataType: "json",
            headers: {
              "Authorization": "Basic " + btoa(api_key + ":x")
            },

            data: ticket_data,

          }
        );
      }
    );
});

</script>
mafioznick commented 2 years ago

any help?