title: How do I avoid getting the HTTP status code 405?
body: <p>Im trying to use the tvdb.com API (<a href="https://api.thetvdb.com/swagger#!/Authentication/post_login" rel="nofollow noreferrer">docs</a>). For now, I'm just trying to connect and get a JWT token using the /login operation. However I'm running into the HTTP status code <a href="https://i.stack.imgur.com/Ag3jk.png" rel="nofollow noreferrer">405</a>.</p>
  
  <p>Here the code I'm using:</p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  
  &lt;body&gt;
      &lt;p id="demo"&gt;Demo&lt;/p&gt;
      &lt;input type="button" value="Button" id="button" onclick="callAPI();"&gt;
  &lt;/body&gt;
  
  &lt;script src="app.js"&gt;&lt;/script&gt;
  </code></pre>
  
  <p>app.js :</p>
  
  <pre><code>const xhr = new XMLHttpRequest();
  const url = "https://api.thetvdb.com/login";
  const data = JSON.stringify({"apikey":"/*APIKEY*/"});
  
  xhr.responseType = "json";
  xhr.onreadystatechange = function(){
      if(xhr.readyState == XMLHttpRequest.DONE){
          console.log(xhr.response)
      }
  }
  
  function callAPI(){
      xhr.open("POST",url);
      xhr.setRequestHeader("Content-Type","application/json");
      xhr.setRequestHeader("Accept","application/json");
      xhr.send(data);
  }
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/rkTne.png" rel="nofollow noreferrer">OPTIONS</a></p>
  
  <p>Doesnt it say here that I may use POST?</p>