title: Error 405: Method not Allowed on DELETE and PUT
body: <p>I followed this <strong><a href="https://spring.io/guides/gs/accessing-data-mysql/" rel="nofollow noreferrer">spring tutorial</a></strong> and everything worked fine. After this, I decided to add <strong>delete</strong> and <strong>modify</strong> funcionalities. I've implemented them, but when I try to use them, I got the following <strong>error</strong>:</p>
  <blockquote>
  <p>{&quot;status&quot;:405,&quot;error&quot;:&quot;Method Not Allowed&quot;,&quot;message&quot;:&quot;Request method 'POST' not supported&quot;,&quot;path&quot;:&quot;/demo/delete&quot;}</p>
  <p>{&quot;status&quot;:405,&quot;error&quot;:&quot;Method Not Allowed&quot;,&quot;message&quot;:&quot;Request method 'POST' not supported&quot;,&quot;path&quot;:&quot;/demo/modify&quot;}</p>
  </blockquote>
  <p>The commands that I'm executing:</p>
  <pre><code>curl localhost:8080/demo/delete -d name=First
  
  curl localhost:8080/demo/modify -d name=First -d email=abc@gmail.com
  
  //if the name doesn't exist in both methods, it will return &quot;Nonexistent user!&quot;
  </code></pre>
  <p>Below are the following code of:</p>
  <p><strong>MainController.java</strong></p>
  <pre><code>package com.example.accessingdatamysql;
  
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Controller;
  import org.springframework.web.bind.annotation.*;
  
  @Controller 
  @RequestMapping(path=&quot;/demo&quot;) 
  public class MainController {
      @Autowired 
      private UserRepository userRepository;
  
      @PostMapping(path=&quot;/add&quot;) 
      public @ResponseBody String addNewUser (@RequestParam String name, 
             @RequestParam String email) {
  
          User n = new User();
          n.setName(name);
          n.setEmail(email);
          userRepository.save(n);
          return &quot;Saved\n&quot;;
      }
  
      @GetMapping(path=&quot;/all&quot;)
      public @ResponseBody Iterable&lt;User&gt; getAllUsers() {
          return userRepository.findAll();
      }
  
      /* ----------------- NEW METHODS THAT I'VE CREATED ----------------- */
  
      @DeleteMapping(path=&quot;/delete&quot;)
      public String delete(@RequestParam String name) throws Exception {
          if(userRepository.findByName(name).equals(null)) {
              System.out.println(&quot;Nonexistent user!\n&quot;);
          }
          userRepository.deleteByName(name);
          return &quot;User successfully deleted!\n&quot;;
      }
  
      @PutMapping(path=&quot;/modify&quot;)
      public String modify(@RequestParam String name, @RequestParam String email) throws Exception {
          if(userRepository.findByName(name).equals(null)) {
              System.out.println(&quot;Nonexistent user!\n&quot;);
          }
  
          userRepository.deleteByName(name);
          User n = new User();
          n.setName(name);
          n.setEmail(email);
          userRepository.save(n);
          return &quot;User successfully modified!\n&quot;;
      }
  }
  </code></pre>
  <p><strong>User.java</strong></p>
  <pre><code>package com.example.accessingdatamysql;
  
  import javax.persistence.Entity;
  import javax.persistence.GeneratedValue;
  import javax.persistence.GenerationType;
  import javax.persistence.Id;
  
  @Entity
  public class User {
  
      @Id
      @GeneratedValue(strategy=GenerationType.AUTO)
      private Integer id;
  
      private String name;
  
      private String email;
  
      public Integer getId() {
          return id;
      }
  
      public void setId(Integer id) {
          this.id = id;
      }
  
      public String getName() {
          return name;
      }
  
      public void setName(String name) {
          this.name = name;
      }
  
      public String getEmail() {
          return email;
      }
  
      public void setEmail(String email) {
          this.email = email;
      }
  }
  </code></pre>
  <p><strong>UserRepository.java</strong></p>
  <pre><code>package com.example.accessingdatamysql;
  
  import org.springframework.data.repository.CrudRepository;
  
  import com.example.accessingdatamysql.User;
  
  public interface UserRepository extends CrudRepository&lt;User, Integer&gt; {
  
      public User findByName(String name);
      public void deleteByName(String name);
  }
  </code></pre>
  <p>I've no idea what's happening here. I've searched for other similar questions like that with the same error but none of them solved my problem.</p>