title: How to create a webhook on a repository on the GitHub web api using AJAX?
body: <p>I am experimenting with Webhooks in the GitHub api. I got one working by doing it manually as in going into my repository and clicking into the setting and enabling a web hook. But now I want to do this in AJAX and I am getting problems. Anytime I try to send a POST to the web api it fails with a 400 (Bad Request). I am not sure where I am going wrong with my code.</p>
  
  <pre><code>function createWebHooksOnRepos(token){
  const webhookURL = "https://api.github.com/repos/DanoBuck/AlgorithmsAndDataStructures/hooks";
  
  const json = {
      "name": "WebHook",
      "active": true,
      "events": [
          "issue_comment",
          "issues"
      ],
      "config": {
          "url": "http://39a40427.ngrok.io/api/webhooks/incoming/github",
          "content_type": "json"
          }
  };
  $.ajax({
      headers: {
          "Authorization": "Token " + token
      },
      url: webhookURL,
      data: json,
      type: "POST",
      dataType: "json",
      success: function(data){
          console.log(data);
      }
  });
  </code></pre>
  
  <p>}</p>
  
  <p>Thank you</p>