title: Spring Boot REST method not allowed - 405 error Request method 'GET' not supported
body: <p>I have created two tables in my application, one for users and one for pets.  I have implemented two controllers that will get all, insert into, update and delete an array list which is connected to a mongo db. the getAll and delete functions work correctly but when I am trying to update or insert using POST or PUT I am getting a 405 error - Request method 'GET' not supported</p>
  
  <p>The Pets Controller is:</p>
  
  <pre><code>@RestController
  
  @RequestMapping(value = "/index/pets")
  
  @Api(name = "Pet Adoptions ", description = "Provides a list of methods that manage Pet Adoptions", stage = ApiStage.RC)
  
  
  public class PetController {
  private PetRepository petRepository;
  
      public PetController(PetRepository petRepository)
      {
          this.petRepository = petRepository;
      }
  
      //@RequestMapping (value = "/all", method = RequestMethod.GET)
      @ApiMethod(description = "Get all pets from Database")
      @GetMapping("/all")
      public List&lt;PetAdoption&gt; getAll() {
          return petRepository.findAll();
      }
  
      @ApiMethod(description = "create new pet")
      @PutMapping
      public void insert (@RequestBody PetAdoption petAdoption)
      {
          this.petRepository.insert(petAdoption);
          //this.petRepository.findAll();
      }
  
      @ApiMethod(description = "this will insert/update depending on whether pet exists")
      @PostMapping
      public void updatePet(@RequestBody PetAdoption petAdoption){
          this.petRepository.save(petAdoption);
          //this.petRepository.findAll();
      }
  
      @ApiMethod (description = "this will remove a pet")
      @RequestMapping(value="/delete/{id}", method = {RequestMethod.DELETE, RequestMethod.GET})
      public void delete (@PathVariable("id") String id){
          this.petRepository.deleteById(id);
          this.petRepository.findAll();
      }
  </code></pre>
  
  <p>I have tried adding changing the @Put/Post Mappings for each method to:</p>
  
  <pre><code>@RequestMapping( method = {RequestMethod.POST, RequestMethod.GET})
      @RequestMapping( method = {RequestMethod.PUT, RequestMethod.GET})
  </code></pre>
  
  <p>and tried changing the @RequestMapping to:</p>
  
  <pre><code>@RequestMapping(value = "/index/pets", {method = {RequestMethod.PUT,  RequestMethod.POST, RequestMethod.GET}) 
  </code></pre>
  
  <p>I'm getting an error though. This is the response I'm getting when trying to perform a PUT or POST request in Postman to localhost:8082/index/pets:</p>
  
  <pre><code>{
      "timestamp": "2019-09-10T19:16:15.861+0000",
      "status": 405,
      "error": "Method Not Allowed",
      "message": "Request method 'GET' not supported",
      "path": "/index/pets"
  }
  </code></pre>
  
  <p>The full response is here </p>
  
  <p><a href="https://i.stack.imgur.com/rlHUQ.png" rel="nofollow noreferrer">header response</a></p>