title: Error 405 Method Not Allowed when sending a PUT AJAX request to Spring Boot with jQuery?
body: <p>I'm getting 405 in console, when I send PUT request.</p>
  <p>Here is my ajax call, which is part of bigger function:</p>
  <pre><code>triggerPutRequest(id, stringDate, isDone, title)
                  .then((data) =&gt; {
                      console.log(data);
                  })
                  .catch((error) =&gt; {
                      alert(error);
                  });
  
  
  function triggerPutRequest(isDone, id, stringDate, title) {
      
          return new Promise((resolve, reject) =&gt; {
      
              $.ajax({
                  type: 'PUT',  // http method
                  url: window.location + &quot;api/tasks&quot;, //endpoint on our backend
                  contentType: &quot;application/json; charset=utf-8&quot;,
                  dataType: 'json',
                  data: JSON.stringify({
                      &quot;id&quot;: id,
                      &quot;title&quot;: title,
                      &quot;dueDate&quot;:  convertDateToString(new Date(datepicker.value)),
                      &quot;done&quot;: isDone,                                         
                  }),
      
                  success: function (data) {
                      resolve(data)
                  },
                  error: function () {
                      reject(&quot;string&quot;)
                  }
              });
      
          })
      
      }
  </code></pre>
  <p>In my Spring Boot I have simple Task model object with omitted unrelevant fields:</p>
  <pre><code>public class Task {
      
          @Id
          @GeneratedValue(strategy = GenerationType.IDENTITY)
          @Column(name = &quot;id&quot;, unique = true, nullable = false)
          private int id;
  
          @Column(name = &quot;due_date&quot;, unique = false, nullable = false)
          @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = &quot;dd-MM-yyyy&quot;)
          private LocalDate dueDate;
  
          @NotEmpty(message = &quot;cannot be empty string&quot;)
          @Column(name = &quot;title&quot;, unique = true, nullable = false)
          private String title;
      
          @Column(name = &quot;done&quot;, unique = false, nullable = false)
          private boolean done;
  }
  </code></pre>
  <p>My controller class in Spring Boot and endpoint method for updating look like this:</p>
  <pre><code>@RestController
  @RequestMapping(value=&quot;/api/tasks&quot;)
  
  public class TaskController {
      @PutMapping(value=&quot;/&quot;, consumes=&quot;application/json&quot;)
      public ResponseEntity&lt;Task&gt; updateTask(@RequestBody Task taskToBeUpdated){
          //update object logic
          return new ResponseEntity&lt;Task&gt;(newlyAddedTask, HttpStatus.OK);
      }
  }
  </code></pre>