title: Testing POST Request in REST
body: <p>I am using Postman (chrome extension) to test this REST service and I am able to successfully test GET and DELETE: <code>http://localhost:8080/mt-rest/rest/user/321</code>, but not POST, even after giving form data.
  I get.. The server refused this request because the request entity is in a format not supported by the requested resource for the requested method. What am I doing wrong here?</p>
  
  <p><img src="https://i.stack.imgur.com/YRPO8.jpg" alt="enter image description here"></p>
  
  <pre><code>@Controller
  @RequestMapping("rest")
  public class TestController {![enter image description here][2]
  
      @Autowired
      private MultitenantService service;
  
      @RequestMapping(value = "/user/{id}", method = RequestMethod.GET)
      @ResponseBody
      public User getUserInfo(@PathVariable Long id) {
          return service.getUser(id);
      }
  
      @RequestMapping(value = "/user", method = RequestMethod.GET)
      @ResponseBody
      public List&lt;User&gt; getCustomers() {
          return service.getUsers();
      }
  
      @RequestMapping(value = "/user/{id}/todo", method = RequestMethod.GET)
      @ResponseBody
      public List&lt;TodoItem&gt; getTransactions(@PathVariable Long id) {
          return getUserInfo(id).getTodoItems();
      }
  
      @RequestMapping(value = "/user/{id}/todo", method = RequestMethod.POST)
      @ResponseBody
      public List&lt;TodoItem&gt; addTransaction(@PathVariable Long id, @RequestBody TodoItem todoItem) {
  
          User user = getUserInfo(id);
          user.getTodoItems().add(todoItem);
  
          service.save(user);
  
          return user.getTodoItems();
      }
  
      @RequestMapping(value = "/user/{id}/todo/{todoId}", method = RequestMethod.DELETE)
      @ResponseBody
      public User addTransaction(@PathVariable Long id, @PathVariable Long todoId) {
  
          User user = getUserInfo(id);
  
          user.deleteTodo(todoId);
  
          service.save(user);
  
          return getUserInfo(id);
      }
  }
  </code></pre>
  
  <p><strong>Update:</strong></p>
  
  <p>In my POST method I changed from @RequestBody to @ModelAttribute and now I am getting </p>
  
  <pre><code>org.springframework.web.util.NestedServletException: Request processing failed; nested exception is javax.validation.ConstraintViolationException: Validation failed for classes [net.tajzich.mt.domain.TodoItem] during persist time for groups [javax.validation.groups.Default, ]
  List of constraint violations:[
      ConstraintViolationImpl{interpolatedMessage='may not be null', propertyPath=name, rootBeanClass=class net.tajzich.mt.domain.TodoItem, messageTemplate='{javax.validation.constraints.NotNull.message}'}
  </code></pre>
  
  <p>]</p>