skip to Main Content

BY THIS CODE PLEAS HELP HOW TO CREATE ZENDESK TICKET

<script type = "text/javascript" >
  $(function() {
    $("#btnGet").click(function() {
      $.ajax({
        url: 'https://xxxx.zendesk.com/api/v2/tickets/1.json',
        contentType: 'application/json',
        type: 'POST',
        data: JSON.stringify({
          "ticket": {
            "subject": "Tst SUB",
            "comment": {
              "body": "Test BODY"
            }
          }
        }),
        success: function(response) {
          alert("Hello: Success");
        },
        failure: function(response) {
          alert("Fail");
        },
        error: function(response) {
          alert("Error");
        }
      });
    });
  });
</script>

2

Answers


  1. It appears that you have some issues with the body section.

    "comment": { "body": :Test BODY" }
    

    try

    "comment": { "body": "Test BODY" }
    
    Login or Signup to reply.
  2. Your code works, the only mistake is in the request url. When creating a new ticket you don’t need to add any ticket number.

    Just edit the url removing 1.json and leave 'https://xxxx.zendesk.com/api/v2/tickets'

    Also, if you’re not sending the request from within Zendesk (e.g. a custom app) you need to authenticate the request.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search