title: Spring 4 RestController: not receiving data from PUT request
body: <p>I'm trying to build a very basic REST API using Spring. </p>
  
  <p>My URL endpoints are:</p>
  
  <pre><code>GET    /notes
  GET    /notes/{noteId}
  POST   /notes
  PUT    /notes/{noteId}
  DELETE /notes/{noteId}
  </code></pre>
  
  <p>All these endpoints work perfectly fine as expected except the <code>PUT</code> request which I want to run to update an item. </p>
  
  <p>The problem is that data is not being received via <code>PUT</code>, where as it works fine for <code>POST</code>. </p>
  
  <p>Here's my controller; I've tested it by adding a method identical to the <code>update</code> method but using <code>POST</code> and that works fine. I don't know why?</p>
  
  <pre><code>package notes;
  
  import org.springframework.web.bind.annotation.*;
  
  @RestController
  @RequestMapping("/notes")
  public class NotesController {
  
      ...
  
      @RequestMapping(value="/{noteId}", method=RequestMethod.PUT)
      public Response update(@PathVariable Integer noteId, Note note) {
  
          return new Response("Note Updated", note);
  
      }
  
      @RequestMapping(value="/{noteId}", method=RequestMethod.POST)
      public Response updateWithPost(@PathVariable Integer noteId, Note note) {
  
          return new Response("Note Updated", note);
  
      }
  
      ...
  
  }
  </code></pre>
  
  <p>Using postman, I've tested <code>POST</code> <a href="http://127.0.0.1:8080/notes/5" rel="nofollow">http://127.0.0.1:8080/notes/5</a> and the response was:</p>
  
  <pre><code>{
      "message": "Note Updated",
      "note": {
          "id": null,
          "title": "Hello World detail content",
          "text": "Hello World",
          "createdAt": "72, Mar 2015",
          "updatedAt": "72, Mar 2015"
      }
  }
  </code></pre>
  
  <p>But for <code>PUT</code> <a href="http://127.0.0.1:8080/notes/5" rel="nofollow">http://127.0.0.1:8080/notes/5</a> with exactly same data the response was: </p>
  
  <pre><code>{
      "message": "Note Updated",
      "note": {
          "id": null,
          "title": "",
          "text": "",
          "createdAt": "72, Mar 2015",
          "updatedAt": "72, Mar 2015"
      }
  }
  </code></pre>
  
  <p><strong>Update Request</strong>
  For both <code>PUT</code> &amp; <code>POST</code> request I'm sending the same test data: </p>
  
  <pre><code>title: Hello World
  text: Hello World detail content
  </code></pre>
  
  <p><strong>Response Class</strong></p>
  
  <pre><code>package notes;
  
  public class Response {
  
      private String message;
      private Note note;
  
      public Response(String text) {
          setMessage(text);
      }
  
      public Response(String text, Note note) {
          setMessage(text);
          setNote(note);
      }
  
      //...getters/setters
  }
  </code></pre>
  
  <p><strong>Note Class</strong></p>
  
  <pre><code>package notes;
  
  import java.text.SimpleDateFormat;
  import java.util.Date;
  
  public class Note {
  
      private Integer id = null;
      private String title = "";
      private String text = "";
      private Date createdAt = new Date();
      private Date updatedAt = new Date();
  
      public Note() {}
  
      public Note(String title, String text) {
          this.setTitle(title);
          this.setText(text);
      }
  
  
      //...getters/setters
  }
  </code></pre>
  
  <p><strong>ApplicationConfig</strong></p>
  
  <pre><code>package notes;
  
  import org.springframework.context.annotation.*;
  import org.springframework.web.servlet.config.annotation.EnableWebMvc;
  
  @EnableWebMvc
  @Configuration
  public class ApplicationConfig {
  
  }
  </code></pre>
  
  <p>I don't know why this is not working?</p>